Garphics.FontName does nothing?

I’m converting some Graphics code to API 2.0 not by choice for the PDF engine.

When I use FontName instead of TextFont, the font never sets – even for a regular Graphics display on a canvas.

Has anyone else seen this?

Why won’t the Analyzer find these deprecation? Why did I have to run-exception-fix-repeat this? Why do I have to even do this update @Javier_Menendez ?

This is a fundamental showstopper and I’m shocked that nobody else has run into this?

Hi @Tim_Parnell PDFDocumemt is API 2, so it uses the methods/properties names from API 2

Shouldn’t you be able to still use API1 code too?

Or has Xojo changed that?

Nope it raises an exception.

But the analyzer won’t find them for you.

You have to run-exception-fix-retry.

And then I find this problem. I can’t set the FontName. It doesn’t even work for a normal Canvas Paint Graphics object.

So I’m left stopped with no fixes, and a less than fulfilling response from staff.

Are you using the true name of the font?

No experience yet, based my comment on case #67267

myPage.FontName = "Honey I Stole Your Jumper" // the True name of the Font
// myPage.FontName = "Honey"
// myPage.FontName = "Honey.ttf" // the Filename

Hmm, in 2021 R3.1 I happily mix API2 and API1 - so the requirement to stick with API2 for everything seems to be something new (but feel free to correct me on that).

What happens if you

  1. save a BINARY project from 2019r1 or a version BEFORE 2019r3
  2. name it Default Desktop Project.xojo_binary_project
  3. place it in the Project Templates directory right next to the IDE application

Now every new project will use that old form as the template and create API1 compatible projects

You might still need to edit the text file that is the project manifest (ends with .xojo_project) and change the first few lines to make it so the project opens flawless in o old version

In a text project from 2022r1.1 you might see

RBProjectVersion=2022.011
MinIDEVersion=20200200
OrigIDEVersion=20210301

as the first few lines

Edit those to say 2018.03 (in their respective forms)

In an XML project you will see something similar right at the beginning

No one said that you need API2 for everything.

You need API2 for new things in Xojo (DesktopXYZ controls, PDFDocument, etc.)

But unless I misunderstood Tim he is talking about a graphics object. That is inside a PDFdocument but it should still be a graphics object and understand the API1 ways eg FontName instead of TextFont …

What I understand is that FontName is not working for him for PDFDocument (required) and not even for regular Graphics display on a canvas (not required).

I guess that TextFont is working for Tim on a regular Graphics display on a canvas.

I’m not sure if this is what is happening with Tim.

My other guess is that Javier did not understood Tim’s problem.

It would be good to have some code/example project to look at…

Instead of doing more guessing:

  1. I created a new project with a Canvas using Xojo 2017r1.1
  2. Saved it as a Binary Project
  3. Opened it in Xojo 2022r1.1
  4. Only changed TextFont to FontName
  5. And these are the results, both on Canvas and on PDF

Hi @Tim_Parnell

When I set the “Analysis Warnings…” options so it includes “item1 is deprecated. You should use item2 instead”, I’m getting warnings for TextFont and, in this case, also TextSize:

I’ll have to send the project in because I didn’t have either of those successful results. It’s upgrading a Shorts project, so I was expecting it to be as easy as using the existing Graphics code. At least that’s how PDFDocument’s been advertised.

Sorry to have disappeared, I wish I could have been more responsive.

Using the Graphics class methods and properties is how PDFDocument was advertised :slightly_smiling_face:

Anyway on one of my side-projects I had to convert myself a large project from API 1.0 to API 2.0 (everything, including migrating controls to DesktopUIControls). It didn’t took me more than 4 hours using, mostly, the results from Analyze Project.

I’ve converted projects to API 2.x in short time, but when that happened everything from Xojo was working as expected. Framework functions to analyzer.

When pausing the debugger, the PDFGraphics object is showing me “Times” as the font, which as a string literal does not exist in this project, nor what I would expect from a property that doesn’t do anything at all.

Figured it out, return value of a function to associate the font name was a Variant. The actual value being returned was a String, but that was confusing FontName somehow.

Forcing a Variant.StringValue upon this code fixes the problem.

:man_facepalming:

7 Likes