Files |  Tutorials |  Articles |  Links |  Home |  Team |  Forum |  Wiki |  Impressum

Aktuelle Zeit: Do Mai 30, 2024 03:35

Foren-Übersicht » English » English Programming Forum
Unbeantwortete Themen | Aktive Themen



Ein neues Thema erstellen Auf das Thema antworten  [ 5 Beiträge ] 
Autor Nachricht
 Betreff des Beitrags: unit conversion (pt to opengl units)
BeitragVerfasst: Di Okt 06, 2009 18:18 
Offline
DGL Member
Benutzeravatar

Registriert: Di Jul 01, 2003 18:59
Beiträge: 887
Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
How would i convert the size of a font that is give in pt ot opengl unit. I guess i have to use px as an intbetween step. Thanks for your answers in advance.

_________________
http://3das.noeska.com - create adventure games without programming


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Di Okt 06, 2009 20:55 
Offline
DGL Member
Benutzeravatar

Registriert: Di Mai 18, 2004 16:45
Beiträge: 2622
Wohnort: Berlin
Programmiersprache: Go, C/C++
1pt is 1/72 inch but OpenGL don't specified a unit. This is your job but if you use ortho then you work on pixel base and now you can look on your system how many pixel per inch you display can do and so you can convert pt to pixel.

_________________
"Wer die Freiheit aufgibt um Sicherheit zu gewinnen, der wird am Ende beides verlieren"
Benjamin Franklin

Projekte: https://github.com/tak2004


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Mi Okt 07, 2009 18:56 
Offline
DGL Member
Benutzeravatar

Registriert: Di Jul 01, 2003 18:59
Beiträge: 887
Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
e.g if i specyify 640x480 in glortho mode and my real screen size is 1024x768. How do i get the unit size? Posible Solution: divide real screensize with glortho screensize? Does that give pixels per opengl unit?

but a third size comes into play EM . e.g. a font is stored as units per em and 1 em being the current font size ? :roll:
a ttf font is supposed to have 2048 units per em. http://www.w3.org/TR/SVG/fonts.html

Using google i found the following table:
http://sureshjain.wordpress.com/2007/07/06/53/
stating that:
12pt = 16px = 1em = 100%

@tak2004:
with 1pt is 1/72 inch gives me yet another size. Also how do i determine a monitors pixels per inch (or dpi dots per inch?) So in the end that should tell me how many pixels there are in an inch.
but 12/72 gives about 0,16666 so that's 16px.

Now how do get from the 2048 unit per em to a font that is drawn at the correct size.

768/480 give 1,6 so an opengl unit would be 1,6 pixel?
assuming i want to draw a font at 12pt i would need to draw something at 16px heigh.
16 / 1,6 states to me i should draw something at 10 opengl units heigh.
i now assume that 10 opengl units is 1em and thus equals the 2048 units per em. So 2048 = 10.
Now i can calculate from a font point to opengl point.

I should try to write some code for this. To see if my theory works in practice.

Let me know if the above makes sense or not. Thanks for your answers in advance.

_________________
http://3das.noeska.com - create adventure games without programming


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: Fr Okt 09, 2009 22:39 
Offline
DGL Member
Benutzeravatar

Registriert: Di Mai 18, 2004 16:45
Beiträge: 2622
Wohnort: Berlin
Programmiersprache: Go, C/C++
Em is the best choice you can get. This is the font unit system which used in the ttf files. You can read from a font file the default metric and then if it exists the metric of special symbols. This metric consists of several information like bounding box of a symbol, the 3 horizontal lines(i don't remember the name something like acent, decent or so). To get the height of a text you have to use a more simple equation for the 3 horizontal lines. After that you have to look in the lookup table for the metric of a symbol, there are 2 possible ways, if i remember right, the first is if there are no extra metric data and the other if there are special metric data. There is a simple equation on the microsoft documentation which show how to use the information of the default or special metric information to and divide it with the information of the line(2048units per em isn't a constant value).
There's past some time since i looked at this topic and it was for Aya and not me, so the best way will be to ask her per private message, because she wrote a ttf file reader and wrote a code to render it in opengl. I only made some researches for her. If you search in the forum for the last thread on this topic you can find the links to the sites of apple, microsoft, adobe and a perl implementation. There you found all equations, background infos and content of a true type font.

_________________
"Wer die Freiheit aufgibt um Sicherheit zu gewinnen, der wird am Ende beides verlieren"
Benjamin Franklin

Projekte: https://github.com/tak2004


Nach oben
 Profil  
Mit Zitat antworten  
 Betreff des Beitrags:
BeitragVerfasst: So Okt 11, 2009 11:19 
Offline
DGL Member
Benutzeravatar

Registriert: Di Jul 01, 2003 18:59
Beiträge: 887
Wohnort: (The Netherlands)
Programmiersprache: fpc/delphi/java/c#
I let windows calculate the font outlines and store those paths as svg paths in a text file. Somehow that seems to give 1000 units per em. So far i get away using that as a constant value.

Using 1000 for the units per em, and asuming all screens dpi are 72, and asuming 1px is 1unit in opengl. I can now draw some fonts at what seems to be the correct size.

To finetune things i need to be certaint that the font saving routine makes the font 1000 units per em.

Need to find a way to read out screen dpi and pass it the glvg font class.
In the case of glortho and real screen size are not equal to each other i have to pass that info also to the glvg font class.

Using aya's ttf loader would be usefull on converting ttf files to svg fontpaths.

_________________
http://3das.noeska.com - create adventure games without programming


Nach oben
 Profil  
Mit Zitat antworten  
Beiträge der letzten Zeit anzeigen:  Sortiere nach  
Ein neues Thema erstellen Auf das Thema antworten  [ 5 Beiträge ] 
Foren-Übersicht » English » English Programming Forum


Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 6 Gäste


Du darfst keine neuen Themen in diesem Forum erstellen.
Du darfst keine Antworten zu Themen in diesem Forum erstellen.
Du darfst deine Beiträge in diesem Forum nicht ändern.
Du darfst deine Beiträge in diesem Forum nicht löschen.
Du darfst keine Dateianhänge in diesem Forum erstellen.

Suche nach:
Gehe zu:  
cron
  Powered by phpBB® Forum Software © phpBB Group
Deutsche Übersetzung durch phpBB.de
[ Time : 0.008s | 14 Queries | GZIP : On ]