font heights

1)
I had assumed that the units returned from dc.getFontHeight would be pixels but it is not stated in the documentation.
Using Gfx.FONT_NUMBER_MEDIUM and a Fenix 3 HR - i get a height of 60 from getFontHeight.

When i draw a few numbers on the screen, and add a scale drawn with dc.drawLine for reference, it does not appear to be any more than 40px high. Since it is a number font, i am not sure descenders is an issue.

So this makes me wonder if the units are perhaps 'points' or something. Maybe i need to scale by 150 DPI?

I searched and have not found any mention of DPI (dots per inch), which i think would be used to convert from points to pixels.

My objective is to position graphics knowing the text dimensions - but i am wasting a lot of space due what appears to be 60 rather than 40 from getFontHeight.
This is the worst example i have found so far - other watches and fonts perhaps not so far out.

2)
I find it hard to find things in the documentation. The API docs have a nice search tool. This forum has a search tool that helps sometimes. Then there are all the 'programmers guide' pages which are not searchable as far as i can tell. So there is good info in there, however i find it can be hard to find. And then the samples are good to, so i have a full text search of all the samples going pretty often too.
It would be most excellent if all this documentation were combined into a PDF of CHM(microsoft help file). Then you could just do simple text search of all the sources.

Is there an easier way that i am missing?
  • Former Member
    Former Member over 7 years ago
    To quickly touch on your question about searchable documentation, the programmers guide, readme, and user experience guide should be included as *.html files in the root level of every SDK release.
  • It's in pixels. Depending on the device, and the specific font, it's not always just the character itself, but extra space on the top and/or bottom. An example of this is number fonts on an f3. Much more reasonable sizes on the f5s for example.

    What you can do is this:

    -figure out if your on a f3 or a f5s
    -if on a f3, when you do dc.getFontHeight() use an "adjustment" like "dc.getFontHeight()-x" to get things looking correctly.
  • When i draw a few numbers on the screen, and add a scale drawn with dc.drawLine for reference, it does not appear to be any more than 40px high. Since it is a number font, i am not sure descenders is an issue.


    What do you see when you draw the text with a background colour that is distinct from your watch face (or data field) background?
  • What do you see when you draw the text with a background colour that is distinct from your watch face (or data field) background?

    Been there, done that...

    Let's say the WF has a black background, and when you set the background for the dc.drawText() to be blue. The blue is in the entire getFontHeight(), so on a f3, it's got extra at the top and bottom, while on the f5s, its just behind the characters.

    This is a quirk, not a bug to me, as I don't expect it to change on the f3 family of devices. And if it did, it could actually break a bunch of apps that had been coded for the quirk.
  • The blue is in the entire getFontHeight(), so on a f3, it's got extra at the top and bottom,


    Oh, I get that, but I just wanted mikethebum to see for himself what the actual 60px includes (for the particular font on the particular device).
  • wow several helpful points.
    - Will try working from the docs in the SDK rather than the website - did not realize the same content was in only a few pages in SDK vs many small ones on website!
    I merged about 5 key HTML files into a single large PDF - so now i can do searches easily in PDF. Alas i have not yet got to all the small pages for each function. Maybe some day i will get that sorted into one giant file for searching.

    - now using text background to see extents - great

    - and will now better understand offsets to text and getFontHeight

    cheers all!
  • Just a short FYI,

    I was able to combine all the HTML files provided in the SDK into a single searchable PDF file, complete with a full 'outline' giving access to all the individual parts.
    This includes the guides and all the details for each class and method, even includes the graphics within the documents.
    I can now do a full text search within this file for any keyword.
    Working better for me than what i was doing before, hunting around in the various documents.
    I did this using the current SDK 2.2.6, but have it largely automated so should be possible to redo it fairly easily as new SDK are released.
    Maybe some have other ways of doing things - but it seems to me that something along these lines would be a good addition to what Garmin offers
  • Maybe you could attach this or if too large, post somewhere? I find the html documentation not ideal and would prefer a searchable pdf.
  • I think the 2.3.1 SDK is coming pretty soon (fingers crossed!), and you may want to wait for that before posting, as 2.2.6 will be outdated at that time. I know Brandon and Coleman have posted a number of times about some of the reworking of the doc they are doing for 2.3.x. You'll see some in the 2.3.0.beta1 SDK, but there likely will be more with 2.3.1
  • Well i hope this is ok with the Garmin folks.
    It is just a duplication of the documents they provided in a new format.
    The file is 14MB in size currently.
    Represents SDK 2.2.6.

    https://www.dropbox.com/sh/d0h9khfq25xcepx/AACMwTAop7AISN1C00Xt6Qhla?dl=0

    See what you think about the usefulness of this.