OpenType regex possibility

Get help with FontCreator here. Please do not post feature requests or bug reports here.
Post Reply
tesbihhan
Posts: 41
Joined: Sun Jan 01, 2017 11:18 am

OpenType regex possibility

Post by tesbihhan »

I am working on a complex arabic font and whlie setting opentype i need some ease like regular expressions.

is it possible to use regex in opentype panel or even code editor.

for example i need much times a regex like .+ or .* (any character one or more times or any character zero or more times)

if it possible it will be very easy to make some codings
tesbihhan
Posts: 41
Joined: Sun Jan 01, 2017 11:18 am

Re: OpenType regex possibility

Post by tesbihhan »

i have to add new subtables or rules for every character

if we can use regex it will be much easier

for example now in code editor

pos @CG_45' lookup PairAdjustment11 @CG_46' @CG_39 @CG_39 @CG_40;
pos @CG_45' lookup PairAdjustment11 @CG_46' @CG_39 @CG_39 @CG_39 @CG_40;
pos @CG_45' lookup PairAdjustment11 @CG_46' @CG_39 @CG_39 @CG_39 @CG_39 @CG_40;

is it possible somthing like that

pos @CG_45' lookup PairAdjustment11 @CG_46' .+ @CG_40;
Attachments
Ekran görüntüsü 2022-10-07 000607.png
Ekran görüntüsü 2022-10-07 000607.png (41.87 KiB) Viewed 1913 times
Ekran görüntüsü 2022-10-07 000657.png
Ekran görüntüsü 2022-10-07 000657.png (39.43 KiB) Viewed 1913 times
Ekran görüntüsü 2022-10-07 000723.png
Ekran görüntüsü 2022-10-07 000723.png (38.63 KiB) Viewed 1913 times
Erwin Denissen
Moderator
Moderator
Posts: 11151
Joined: Fri Oct 04, 2002 12:41 am
Location: Bilthoven, The Netherlands
Contact:

Re: OpenType regex possibility

Post by Erwin Denissen »

This is not possible right now.
Erwin Denissen
High-Logic
Proven Font Technology
ShawnDion
Posts: 34
Joined: Sun Aug 24, 2014 1:08 pm

Re: OpenType regex possibility

Post by ShawnDion »

tesbihhan wrote: Thu Oct 06, 2022 9:10 pm i have to add new subtables or rules for every character

if we can use regex it will be much easier

for example now in code editor

pos @CG_45' lookup PairAdjustment11 @CG_46' @CG_39 @CG_39 @CG_40;
pos @CG_45' lookup PairAdjustment11 @CG_46' @CG_39 @CG_39 @CG_39 @CG_40;
pos @CG_45' lookup PairAdjustment11 @CG_46' @CG_39 @CG_39 @CG_39 @CG_39 @CG_40;

is it possible somthing like that

pos @CG_45' lookup PairAdjustment11 @CG_46' .+ @CG_40;
Hi tesbihhan ,

I had previously commented on your post but had failed to get the application I was suggesting to work the application is called FontTools it's a github project using Python version 3.8.0 and installing the pip fonttools you can convert the ttf file to TTX format and well this format give you your font in text format the good news is what you are looking for is in this text file.

I'll make a tutorial on how to use this program with the correct installation settings for Python.

This is not a High-Logic tool and as in any program use at your own risks however your problem was intriguing as I was hunting for a way to change the COLR attribute option that is missing from Font Creator and this gives me the option to do so.

Should take me a few days to make a proper tutorial guide and as always make backups of your work.

Shawn Dion
ShawnDion
Posts: 34
Joined: Sun Aug 24, 2014 1:08 pm

Re: OpenType regex possibility

Post by ShawnDion »

As promised here the information :

How to install FontTools for Windows 10 64 bit and steps to convert a TTF to TTX (XML Format) and Back.

Step 1:
Go to https://www.python.org/downloads/release/python-380/
Scroll down to Files and Download Windows x86-64 executable installer

Step 2: Once the download is complete you should have a file in your Download location called.
python-3.8.0-amd64.exe

Right Click this file and "Run as Administrator.

Step 3: Make sure to check the box : "Add Python 3.8 to Path"
Then click on "Customize installation"

Step 4: On this page make sure that all the options are checked.
Then click "Next" to continue

Step 5: Make sure that "Associate files with Python (requires the py launcher)" is checked and "Create shotrcuts for installed applications" too.

When ready click "Install"

Let the Setup Progress finish installing once done you should see "Setup was successful" if so you can click on "Close"

Press the Windows Key + R ro open the Run dialog.

In this box type CMD and click "Ok" or press Enter.

In the dos window type:
py -m pip install --upgrade pip
This will update Python PIP program for installers..

Close the Dos window.

Step 6: Open the Start Search, type in “env”, and choose “Edit the system environment variables”:
Click the “Environment Variables…” button.

In the section "User variables for <username>"
Click on path and press the Edit button
Click "New" and Paste the following in a new line

%USERPROFILE%\AppData\Local\Programs\Python\Python38\Scripts

Click Ok and Ok again on the other window.

Step 7: Press the Windows Key + R ro open the Run dialog.

In this box type CMD and click "Ok" or press Enter.

In the dos window type:
py -m pip install fonttools
and press "Enter"

If all went well you now have installed Font Tools with the TTX tool.

To convert a font now to TTX (XML text format) go to your folder where it is stored
for example accessing the Documents folder in the dos window type
cd %USERPROFILE%\Documents\Fonts
and press "Enter"

Once there I created the default font with Font Creator myfont.ttf. (Always make sure to backup your font in another location to avoid corruption or loss)
Type
TTX MyFont-Regular.ttf
once done you will have a file called MyFont-Regular.ttx
you can type
notepad MyFont-Regular.ttx
and press "Enter"

You will have Notepad opened up with the font fully editable at this stage it's now a learning process to see how we can do certain things such as a regex.

I recommend learning about XMLStarlet, If I had a copy of said font I could indicate where things need to change or regex to use.

Once your editing is done you can go back to the DOS window and type
TTX myfont.ttx
and this will return it back to TTF fprmat

(I'll be updating this shortly with screenshots of the steps and adding Tree Structures of the TTX file format hope this can help you find a solution to your request)

Shawn Dion

P.S: Do not hesitate to ask questions.
tesbihhan
Posts: 41
Joined: Sun Jan 01, 2017 11:18 am

Re: OpenType regex possibility

Post by tesbihhan »

much thanks for your detailed tutorial

i have some questions. what is the benefit of ttx format

can i use it in other platforms ios android etc.
ShawnDion
Posts: 34
Joined: Sun Aug 24, 2014 1:08 pm

Re: OpenType regex possibility

Post by ShawnDion »

The official document site is https://fonttools.readthedocs.io/en/latest/

I haven't tried it on other platforms yet as it uses Python reason why I found this tool interesting is that once you have converted the TTF to ttx you get access to the internals of the font such as the color tables and condition rules such as the one you had mentioned that you wanted to do.

Ligature components are clear to access and to edit and you get a birds eye view of the glyph info so if you see points that don't match well you can edit at that location.

From a quick search though it does seem that it is android compatible code, I'll have to take a deeper look at it once I finish adding the screenshots for this tutorial.

P.S: Seems for the space issue in chrome there are css tricks to prevent it from happening (Currently reading about it will keep you posted if I find you a display fix)

Shawn Dion
Post Reply