Old 06-06-2015, 01:12 PM   #1
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,281
Default Font size in scripts issue in different platforms Win vs Mac

It seems that this results in different font sizes in pixels between Windows and Mac. Mac being a bit bigger than Windows.
Code:
gfx.setfont(1,"Arial", 14)
gfx.drawstr("This is Arial font size 14")
Is Arial the same font and available in OSX as it is in Windows?
How can we make same font sizes on both platforms?
__________________
HeDaScripts for REAPER
heda is offline   Reply With Quote
Old 06-06-2015, 02:08 PM   #2
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,919
Default

There is few common font (windows linux mac), the simplest list of that came from the web and are called web-safe-font.

There must be something different about how the text is rendered....
I will prepare a/b screenshot windows mac with your region manager window (which has a lot of text).
X-Raym is offline   Reply With Quote
Old 06-06-2015, 02:15 PM   #3
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,281
Default

try this too please
Code:
gfx.setfont(1,"Arial", 14)
gfx.drawstr("This is Arial font size 14")
w,h=gfx.measurestr("This is Arial font size 14")
reaper.ShowConsoleMsg("Width=" .. w)
reaper.ShowConsoleMsg("Height=" .. h)
and tell me if the numbers are different in OSX.
maybe we can find a proportion and do something like this
Code:
OS=reaper.GetOS()
if OS=="OSX32" or OS=="OSX64" then
  gfx.setfont(1,"Arial", 13.8)
else
  gfx.setfont(1,"Arial", 14)
end
edit: mmm I don't know... setting 13 or 13.9 seems to be the same font size in windows. it seems it only accepts integers.
__________________
HeDaScripts for REAPER
heda is offline   Reply With Quote
Old 06-07-2015, 04:18 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,919
Default

it shows :

Code:
Width=150.0Height=18.0
I send you other screenshots in a moment.
X-Raym is offline   Reply With Quote
Old 06-07-2015, 05:07 AM   #5
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,281
Default

Quote:
Originally Posted by X-Raym View Post
it shows :

Code:
Width=150.0Height=18.0
I send you other screenshots in a moment.
in Windows 7 x64:
Width=116.0Height=14.0

so that's the problem

but I think we can't do anything
__________________
HeDaScripts for REAPER
heda is offline   Reply With Quote
Old 06-07-2015, 05:51 AM   #6
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,919
Default

Can't a simple "os based coef multiplicator" do the tricks ?
If OSX then font size = font-size * 0.x ?

The minimum we can do is... bug report :P
X-Raym is offline   Reply With Quote
Old 06-07-2015, 06:03 AM   #7
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,281
Default

it doesn't work for me
maybe it works in Mc? I don't think so.. I think it only accepts integers, which is really strange

Quote:
Originally Posted by heda View Post
edit: mmm I don't know... setting 13 or 13.9 seems to be the same font size in windows. it seems it only accepts integers.
__________________
HeDaScripts for REAPER
heda is offline   Reply With Quote
Old 03-19-2016, 05:03 AM   #8
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,281
Default

bumping this issue. Please fix

It's difficult to program for PC and MAC with different font sizes.

Specially when I don't have a Mac to test it.
Did I hear somebody wants to donate me an old unused mac for testing my scripts on Mac?
__________________
HeDaScripts for REAPER
heda is offline   Reply With Quote
Old 03-19-2016, 05:06 AM   #9
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 2,484
Default

I use OSX in VirtualBox for testing these things (depending on font, and not always has same coefficient).
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl is offline   Reply With Quote
Old 03-19-2016, 06:35 AM   #10
IXix
Human being with feelings
 
Join Date: Jan 2007
Location: mcr:uk
Posts: 3,366
Default

I came across this too just recently. Would be good to have a solution.
IXix is offline   Reply With Quote
Old 03-19-2016, 11:10 AM   #11
ijijn
Human being with feelings
 
ijijn's Avatar
 
Join Date: Apr 2012
Location: Christchurch, New Zealand
Posts: 479
Default

Yes, it's a tricky business. Universality of appearance is why I started using bitmap/signed distance field fonts.
ijijn is offline   Reply With Quote
Old 03-21-2016, 02:24 AM   #12
airon
Human being with feelings
 
airon's Avatar
 
Join Date: Aug 2006
Location: City
Posts: 10,333
Default

What are good ones to pick for OSX and Windows that come installed on both systems ?
__________________
Dialogue/FX Editor & Re-Recording Mixer
(Video)Using Latch Preview
"My ego comes pre-shrunk" - Randy Thom
airon is offline   Reply With Quote
Old 03-21-2016, 02:30 AM   #13
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 5,919
Default

I would say all kind of Web Safe Fonts

For eg, 16 Gorgeous Web Safe Fonts To Use With CSS
X-Raym is offline   Reply With Quote
Old 03-21-2016, 04:04 AM   #14
heda
Human being with feelings
 
heda's Avatar
 
Join Date: Jun 2012
Location: Spain
Posts: 5,281
Default

I use Arial. so It doesn't seem to work with Arial at least
__________________
HeDaScripts for REAPER
heda is offline   Reply With Quote
Old 12-05-2018, 04:20 AM   #15
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,486
Default

Guys, have you found any workaround this problem? I would like to fix this problem in my ReaNoir script.



I use Arial, which is supposed to be cross-platform, but apparently it is not..
Code:
gfx.setfont(1,"Arial", 15)
amagalma is offline   Reply With Quote
Old 12-05-2018, 04:23 AM   #16
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,394
Default

I simply would use a smaller font-size. If I remember correctly, using two smaller should work.
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 12-05-2018, 04:46 AM   #17
geraintluff
Human being with feelings
 
geraintluff's Avatar
 
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 301
Default

I've noticed this with JSFX as well.

Would it work to calibrate against a known string using gfx.measurestr()?

The JSFX equivalent would be:

Code:
gfx_setfont(1, "Arial", 15);

gfx_measurestr("MMMMMMMMMM", str_width, str_height);
font_factor = 90/str_width; // 90 is the width on Windows

gfx_setfont(1, "Arial", 15*font_factor);
I used the width because I've sometimes encountered ambiguity about "font height" vs. "line height" (e.g. includes a 20% padding) - I've no idea whether that's related to this issue or not.

Last edited by geraintluff; 12-05-2018 at 04:53 AM.
geraintluff is offline   Reply With Quote
Old 12-05-2018, 04:47 AM   #18
amagalma
Human being with feelings
 
Join Date: Apr 2011
Posts: 1,486
Default

@mespotine: Hmm.. But I don't want it to be smaller than it is in Windows...

@geraintluff: The problem is that font size must be an integer.. But I'll try it

Last edited by amagalma; 12-05-2018 at 04:53 AM.
amagalma is offline   Reply With Quote
Old 12-05-2018, 09:04 AM   #19
geraintluff
Human being with feelings
 
geraintluff's Avatar
 
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 301
Default

Quote:
Originally Posted by amagalma View Post
@geraintluff: The problem is that font size must be an integer.. But I'll try it
Seems like it worked! Guess I have to apply that fix to all of my own effects now...

Last edited by geraintluff; 12-05-2018 at 09:27 AM.
geraintluff is offline   Reply With Quote
Old 07-12-2019, 08:20 AM   #20
mrelwood
Human being with feelings
 
mrelwood's Avatar
 
Join Date: Nov 2006
Location: Finland
Posts: 1,354
Default

Old thread, issue remains. Biggest problem being of course my favourite, Trebuchet MS, which is about half the size on Windows compared to Mac.

Here are a few 14 px fonts next to a 14 px tall square box. Note also that all images are 300*210 px in size.

Mac:


Windows:


Windows (another resolution):



Arial is not the best after all. Verdana is the closest on different platforms, but it is a very very wide font. Tahoma would be a good second, but it doesn't draw italic.

Has anyone found a font that I haven't thought of, that would (or even could) show roughly in the same size? One that also shows as italic and bold italic?
__________________
______Announcing__mrelwood plugins______
.. MacBook Pro 15" Late '13 .. Scarlett 6i6, Saffire Pro 24 DSP (+ADA8000) .. FCA610 .. EVE: SC207 .. Focal: Alpha 65, CMS 40, Listen Pro ..
mrelwood is offline   Reply With Quote
Old 07-12-2019, 08:51 AM   #21
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,394
Default

Oh, nice. Will add that to Ultraschall-API as gfx.setfont-alternative, if you don't mind...
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 07-12-2019, 08:55 AM   #22
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,076
Default

Sorry, deleted the post after seeing that it had already been covered above. Here's the full function I use:
Code:
-- Usage: Font.set("Arial", 10, "bi")
Font.set = function (font, size, flagStr)

  -- Different OSes use different font sizes, for some reason
  -- This should give a similar size on Mac/Linux as on Windows
  if not string.match( reaper.GetOS(), "Win") then
    size = math.floor(size * 0.8)
  end

  -- Cheers to Justin and Schwa for this
  local flags = 0
  if flagStr then
    for i = 1, flagStr:len() do
      flags = flags * 256 + string.byte(flagStr, i)
    end
  end

  gfx.setfont(1, font, size, flags)
end
Lokasenna is online now   Reply With Quote
Old 07-12-2019, 11:49 AM   #23
mrelwood
Human being with feelings
 
mrelwood's Avatar
 
Join Date: Nov 2006
Location: Finland
Posts: 1,354
Default

Quote:
Originally Posted by Lokasenna View Post
Sorry, deleted the post after seeing that it had already been covered above. Here's the full function I use:
Code:
-- Usage: Font.set("Arial", 10, "bi")
Font.set = function (font, size, flagStr)

  -- Different OSes use different font sizes, for some reason
  -- This should give a similar size on Mac/Linux as on Windows
  if not string.match( reaper.GetOS(), "Win") then
    size = math.floor(size * 0.8)
  end

  -- Cheers to Justin and Schwa for this
  local flags = 0
  if flagStr then
    for i = 1, flagStr:len() do
      flags = flags * 256 + string.byte(flagStr, i)
    end
  end

  gfx.setfont(1, font, size, flags)
end

I would guess that the OS is not detectable for JSFX?
__________________
______Announcing__mrelwood plugins______
.. MacBook Pro 15" Late '13 .. Scarlett 6i6, Saffire Pro 24 DSP (+ADA8000) .. FCA610 .. EVE: SC207 .. Focal: Alpha 65, CMS 40, Listen Pro ..
mrelwood is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:09 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.