OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:49 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Rendered font usage
PostPosted: Mon Jan 28, 2019 2:49 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
Yeah, the caption might not reflect the topic well, sorry. :mrgreen: I have a silly question, maybe you know the answer on it?

My project doesn't have any font rendering capabilities yet. And for some initial stages of it, I thought about using a bitmap font. For the FW part of the project, this scenario could be the main (and only) one at all. The question is, - can I use a resource (bitmap), produced using an installed font on my PC? From the legal perspective. Is such usage allowed? I open Paint, and create .bmp file with all the needed symbols typed in there in white and black and then I use this as a resource for generating the needed font bitmap on the fly (applying simple transformation) inside of my project. This way, I can have font with any FG and BG color combination. And all that vector font rendering with all the visual improvement technics, have been done on the Windows machine, not by my code. Is this usage legal? The question. :) I have no idea, but feel, it's not. I see here at least 2 problems - 1) the font itself, is it free to use it outside of where it was installed? even if my system rasterized it; and 2) - using the result of font rendering with all the technologies applied outside of its intended use. But maybe there are no problems with this, how do you think?

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Mon Jan 28, 2019 4:53 pm 
Offline
Member
Member

Joined: Wed Oct 30, 2013 1:57 pm
Posts: 306
Location: Germany
Hi,

Doing this with Paint seems rather silly (no offense, but it has to be said). Maybe you should look to freely licenced bitmap fonts. uni-vga comes to mind, which has nice Unicode support and is easy to get the 8x16 character bitmaps from (IIRC it ships as BDF, where extracting bitmaps is a breeze).

To answer your question, find out whatever the license of said font is.

Cheers, Leo

_________________
managarm


Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Mon Jan 28, 2019 5:55 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
Thanks. But what's silly about preparing such a resource in Paint? it generates for me a well known and easy to work with bmp formatted image, that I can easily transform (for changing colors)*. Better than anything third party. I can (if I can, of course, that's the question) choose a cute font and have it this way being drawn from the very early stages when I only manage to make first steps with the display system (which isn't easy for SBCs due to horrid or absent documentation). It's for an early development stage! And use some cuteness, like Lucida Console, instead of some ugly eyebleeding free things. Skimming over their (lucida creators) license strengthens my feeling, I need to ask them for approval. But it's not all, the "rendered by Windows" part remains unclear too.

* - say, I pick 100 symbols that are enough and prepare a bmp image 24bpp, 12x20px in form of a bmp image that is 12px in width and 2000px in height. it uses 0xffffff for BG and 0x000000 for FG. It's a bitmap from which it's easy to extract a glyph by index (given they are placed accordingly); but also it could be seen as a "mask" for generating a bitmap for any BG/FG combination. Once on init. Such a file is ~70KB only in size. I don't see it stupid.

PS. Ah, I found the place in the license, where they clearly prohibit such a use. F&ck! :mrgreen:
Quote:
4. Rasterized Image formats. You may include non-scalable, raster graphic images of text generated in pixel form from the Fonts, in electronic documents and graphic image files in industry standard raster image formats including JPEG (Joint Photographers' Expert Group), GIF (Graphics Interchange Format), PNG (Portable Network Graphics), non-vector PICT (non-vector Picture), and BMP (Bitmap) formats, provided that the text images cannot be used for word processing, text editing, text composition, or data entry.

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Mon Jan 28, 2019 6:32 pm 
Offline
Member
Member
User avatar

Joined: Sat Nov 22, 2014 6:33 pm
Posts: 934
Location: USA
First, I don't know why you placed this in the Auto-Delete Forum. Maybe you thought it wasn't worth keeping for future reference. Maybe so. Depends on where it goes, I guess.

Second, due to EFI and recent hardware no longer allowing you to write to 0xB8000 for text output, all OSes, hobby or otherwise, will require at least one (simple) font simply to write to the screen. If you wish to write text to the screen at startup, which most hobby OSes do, you will need a simple, one color font text rendering system. Most of the time, a fixed sized font for this purpose is perfect, so a bitmap font works just fine.

I created a small app that will allow me to create a bitmap of each character along with some information about that particular character.

Here is a screen shot:

Image

I would suggest you do the same.

I use this app and its resulting fonts in the GUI as well, though they are not resizable, i.e.: They are fixed at the size given.

For more complicated factors, resizable fonts, etc., you will need a font rendering engine, a True Type font, or other font engine. They are not easy, nor are they a small task.

Good luck,
Ben

P.S. This app is not available publicly but is available with my book. This app is freely available, with source code, from the home page.


Last edited by BenLunt on Wed Jan 19, 2022 5:13 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Mon Jan 28, 2019 7:17 pm 
Offline
Member
Member

Joined: Wed Mar 30, 2011 12:31 am
Posts: 676
Seeing as no one's really answered the original question...

As soon as you say "from the legal perspective", where you are becomes very important.

In the United States, Japan, and some other jurisdictions, the designs of fonts are not subject to copyright (but their digital representations as font files are), so you can take an existing font design and represent it in a new form freely even if the original font was a licensed, proprietary design. You may have to do that manually to ensure you're not violating the license of the original file, though.

For everywhere else, there are plenty of fonts out there with liberal open-source style licenses, such as the Deja Vu font collection. You can use these fonts, including transforming them into other formats or modifying glyphs, much like you would open source code.

Additionally, as a followup to Ben's post...

If you're looking for an approach to text rendering that is simpler than implementing a TrueType interpreter (and the accompanying Bezier curve glyph rasterization), but more powerful than plain bitmaps, you may want to look at Signed Distance Fields, which is an approach used in many game engines and can provide scalable, anti-aliased text. You can see some samples of an SDF renderer here and here.

_________________
toaruos on github | toaruos.org | gitlab | twitter | bim - a text editor


Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Sat Feb 02, 2019 10:38 am 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 812
Location: Hyperspace
Representing a font in BMP isn't silly. Windows first font file format was a series of header+bmp sequences. Plan 9 uses its own image format with a table of character widths appended. You can literally open the font in an image viewer. Actually, it has two file formats, plain-text font files to tell it the line height and inter-line spacing and to map character ranges to 'subfont' files, then the subfonts are the image files I described.

I think klange has it about right legally. I'd stick with fonts with open licenses myself, otherwise it could be awkward if you get contributors in countries with less liberal copyright laws... I think. :?

I'm guessing this was put in auto-delete by mistake?

_________________
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie


Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Mon Feb 04, 2019 10:02 am 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2646
Location: Devon, UK
BenLunt wrote:
First, I don't know why you placed this in the Auto-Delete Forum. Maybe you thought it wasn't worth keeping for future reference. Maybe so. Depends on where it goes, I guess.

Fixed :)


Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Mon Feb 04, 2019 5:44 pm 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 1584
zaval wrote:
Thanks. But what's silly about preparing such a resource in Paint? it generates for me a well known and easy to work with bmp formatted image, that I can easily transform (for changing colors)*. Better than anything third party.
You should consider the PSF2 format, which is basically a simple bitmap (used by Linux Console, many fonts available for free, legally). The wiki page has example C code with changing colors, just as you wanted. PSF2 is very similar to an uncompressed .bmp, but better because it may contain a unicode table as well, assigning y coordinates to the unicode characters (therefore the bitmap can contain the glyphs in any order, and more characters can point to the same glyph). The wiki page has example on how to decode the optional unicode table if you want that.

Also, talamus has written readpsf / writepsf perl scripts which can convert .psf files into .bmp and vice versa. With that you can convert fonts to bitmaps, open them in Paint, or use in your font renderer. You can use Linux Console fonts without any licencing issues, just give credit.

Cheers,
bzt


Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Tue Feb 05, 2019 2:17 am 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 812
Location: Hyperspace
Now I'm checking out PSF2 format. :)

I like Plan 9's format because it's designed for remote displays and full Unicode coverage, only the necessary subfonts get sent to the remote display, but I guess that may be a bit advanced for the original topic.

_________________
Kaph — a modular OS intended to be easy and fun to administer and code for.
"May wisdom, fun, and the greater good shine forth in all your work." — Leo Brodie


Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Fri Feb 15, 2019 2:23 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
thanks everyone for valuable answers!
why I put it into auto-delete part? yes, I thought, it's a little bit silly question and that place is the best for it. after all, it's not even about programming, rather legal things, and, as I've said, I considered that solution a quick and dirty one for early stages. Of course, as anybody here, I dream, in future, to implement fully fledged vector font rendering engine. :mrgreen:

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Fri Aug 02, 2019 2:03 pm 
Offline

Joined: Wed Jul 17, 2019 2:27 pm
Posts: 18
zaval wrote:
My project doesn't have any font rendering capabilities yet. And for some initial stages of it, I thought about using a bitmap font. For the FW part of the project, this scenario could be the main (and only) one at all. The question is, - can I use a resource (bitmap), produced using an installed font on my PC? From the legal perspective. Is such usage allowed? I open Paint, and create .bmp file with all the needed symbols typed in there in white and black and then I use this as a resource for generating the needed font bitmap on the fly (applying simple transformation) inside of my project. This way, I can have font with any FG and BG color combination. And all that vector font rendering with all the visual improvement technics, have been done on the Windows machine, not by my code. Is this usage legal? The question. :) I have no idea, but feel, it's not. I see here at least 2 problems - 1) the font itself, is it free to use it outside of where it was installed? even if my system rasterized it; and 2) - using the result of font rendering with all the technologies applied outside of its intended use. But maybe there are no problems with this, how do you think?


If you want to do this legally, it would be safer to start out with a font that you have a FLOSS style license to use. I believe pdcurses uses a default bitmap for fonts in their SDL implementation. pdcurses is licensed public domain. You may want to start with what they've done and see what you can reuse from their code and resources.

I also have a list of several mono-spaced (and other fonts). Many are TrueType format but some are bitmap. Check the fonts licenses to make sure they coincide with your goals.
https://lmemsm.dreamwidth.org/3889.html

You can also check sites such as Font Squirrel for public domain fonts to use as a starting point. Most public domain fonts only include a small subset of the Unicode characters. Many FLOSS fonts don't support the whole Unicode character set either. How much of the Unicode character set is supported might be a useful factor when deciding which fonts to use. If you eventually decide to consider TrueType font formats, you may want to look at stb_truetype.h.


Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Sat Aug 03, 2019 3:27 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
thank you for the detailed answer. the font owners answered me and told me I can use their font the way I wanted. let's hope, I formulated it right, they understood it and I understood their answer right as well. :lol:

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
 Post subject: Re: Rendered font usage
PostPosted: Mon Sep 30, 2019 3:59 pm 
Offline
Member
Member
User avatar

Joined: Fri Feb 17, 2017 4:01 pm
Posts: 640
Location: Ukraine, Bachmut
By the way, Microsoft released a monospace, "coder" font, under terms of OFL, that allows almost everything. At least bundling it with your OS as ttf, no matter for commercial use or not. Cascadia Code, the name is and here is the link, for those interested, who yet didn't hear about that. :)
In the hope, the screenshot will be helpful to evaluate the font quickly.
Image

_________________
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 33 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group