rejetto forum

Text Font

0 Members and 1 Guest are viewing this topic.

Offline rokas2491

  • Occasional poster
  • *
    • Posts: 9
    • View Profile
Hi, I have one txt file (notepad). How do I change text font?
 Because if I even change text font on notepad it does not changes on the server, and the font keeps being usually. :)
Thanks
This is the link:
http://88.88.209.56:12/topsongs.txt


Offline XCanG

  • Occasional poster
  • *
    • Posts: 32
  • .do impossible  beat unbeatable
    • View Profile
    • Driver
Hello. Txt files are simple and they contain only information and have no information about styles. So it always will be that font, that setted in your browser! E.g. this is in Firefox:

Chrome have also their own settings.

If you want to use formatted text (that will similar on every device) you have 3 options here: 1) If you want to use it on your PC (not in browser), you may save it as .rtf (Rich Text Format) via WordPad (have in any windows), what support changing fonts, and use it on your server.
But I don't recommend it (it just a simpler solution).
2) The more correct way is using .html files (HyperText Markup Language), what is not hard to do, but first time working in it will be hard. But I will help you.
For that what you want you need in any text editor (Notepad also fine) write that code, where in span you need to paste infromation from your txt. And font: 14pt "Times New Roman"; define your font. For more instructions about that, please read documentation: https://developer.mozilla.org/en-US/docs/Web/CSS/font?v=example
Code: [Select]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
html { min-width: 100%; }
body { font: 14pt "Times New Roman"; width: 100%; }
span { display: block; word-break: normal; word-wrap: break-word; white-space: pre; width: 100%; }
</style>
</head>
<body>
<span>23 Brooke Candy - Living Out Loud
21 Shaun Frank - No Future feat. DYSON
____________your text here____________
3 DJ Katch feat. Hayley - Lights Out (Too Drunk)
1 Scissor Sisters - Comfortably Numb
1 Sam Sparro - The Shallow End (MBS+C3K Remix)
1 Groove Armada - History


From these calculations, Jazler also found out that the first song was logged at 04/19/2017 00:59:18 and last song at 04/25/2017 21:06:09
Jazler RadioStar Export @ 04/25/2017 21:09:16</span>
</body>
</html>
3) If somehow that file is generated by external program, then you need load it into page, so that page need to change a bit:
Code: [Select]
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
html { min-width: 100%; }
body { font: 14pt "Times New Roman"; width: 100%; }
span { display: block; word-break: normal; word-wrap: break-word; white-space: pre; width: 100%; }
</style>
</head>
<body>
<span id="text"></span>
<script>
window.onload = function() {
var t = document.getElementById("text");
var xhr = new XMLHttpRequest();
xhr.open("GET", "topsongs.txt", true);
xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
xhr.onreadystatechange = function() {
if (this.readyState != 4) return;
//console.log(this.status, this.responseText);
t.innerHTML = this.responseText;
}
xhr.send(null);
}
</script>
</body>
</html>
Post-notes: Be sure that your .html file will be placed in same folder, because I use relative path to load it "topsongs.txt". E.g. if you place it in "http://88.88.209.56:12/topsongs/topsongs.html" then "topsongs.txt" will be loaded from "http://88.88.209.56:12/topsongs/topsongs.txt"
You may change path to "/topsongs.txt" and that always will be looking for "http://88.88.209.56:12/topsongs.txt" because "/" at first character mean root.

Also if you not using server for hosting anything else I recommend to you rename file as "index.html" because after that when you open "http://88.88.209.56:12/" you will see that file, instead of HFS interface. This is following by that setting:
« Last Edit: April 26, 2017, 07:38:36 AM by XCanG »


Offline rokas2491

  • Occasional poster
  • *
    • Posts: 9
    • View Profile