Is there any way to change the txt size in a txt_set string format?
function gps_wp_callback (WPnextID, DISnextWP)
txt_set(txt_next_WP, WPnextID)
DISnextWP = DISnextWP/1852
txt_set(txt_Dis_NM, string.format("%.1fNM", DISnextWP))
end
I am building the GI 275 and would like to make the "NM" smaller like it is on the real instrument
Changing font size in string.format
Re: Changing font size in string.format
I understand you want TWO different text sizes in the same string (ie XXX Nm, where the XXX number is bigger than Nm?
I think this is not possible right now in AM, since the same text_style applies to all the characters of a string (color, size), so my advice is to use two different strings side by side, one for the number itself, the other for the “Nm” text. In the text_add() you will be then able to choose whatever color/size you want for both parts.
If visibility is a concern, simply create a group out of the two text_add() and then turn the visibility of the group on/off with one instruction.
That’s what I did for the A320 MCDU, where each character of a line is put in an individual text_add() for complete control. Each character assembled into a line is organised in an array of characters for ease of access.
(See the bottom multicolored line below) Jacques
I think this is not possible right now in AM, since the same text_style applies to all the characters of a string (color, size), so my advice is to use two different strings side by side, one for the number itself, the other for the “Nm” text. In the text_add() you will be then able to choose whatever color/size you want for both parts.
If visibility is a concern, simply create a group out of the two text_add() and then turn the visibility of the group on/off with one instruction.
That’s what I did for the A320 MCDU, where each character of a line is put in an individual text_add() for complete control. Each character assembled into a line is organised in an array of characters for ease of access.
(See the bottom multicolored line below) Jacques
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ
Re: Changing font size in string.format
The solution from JackZ is the easiest. Another, more difficult solution, and I'm not 100% if it'll work, is to make a custom font with bigger and smaller sized characters.
I usually use FontForge if fonts need to be customized. https://fontforge.org/en-US/
I usually use FontForge if fonts need to be customized. https://fontforge.org/en-US/
- Keith Baxter
- Posts: 4685
- Joined: Wed Dec 20, 2017 11:00 am
- Location: Botswana
Re: Changing font size in string.format
Hi,
AM and lua is very powerful when using tables.
Having worked on the Gi 275, Tables are the route IMHO. As Corjan said. Use txt_style to change the format.
Create a table with your styles and call options from your table and concatenate.
Keith
AM and lua is very powerful when using tables.
Having worked on the Gi 275, Tables are the route IMHO. As Corjan said. Use txt_style to change the format.
Create a table with your styles and call options from your table and concatenate.
Keith
AMD RYZEN 9 5950X CPU, Corsair H80I cooler, ASUS TUF GAMING B550-PLUS AMD Ryzen Mother Board, 32Gb ram Corsair Vengeance 3000Mh, MSI GTX960 4G graphics card
Re: Changing font size in string.format
@Keith Baxter
I don't understand how you can concatenate different style in the same string, as txt_styles applies to the whole text string if I'm not mistaken?
I don't understand how you can concatenate different style in the same string, as txt_styles applies to the whole text string if I'm not mistaken?
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ
Re: Changing font size in string.format
here's a simple code based on yours for you to try
Notice the use of halign here
Notice the use of halign here
Code: Select all
txt_next_WP=txt_add("XXXXX", "font:arimo_regular.ttf; size:50; color: red;valign:bottom;", 50, 50, 300, 50)
txt_Dis_NM=txt_add("XXX", "font:arimo_regular.ttf; size:50; color: red; valign:bottom; halign:right;", 50, 100, 95, 50)
txt_Dis_NM_legend=txt_add("Nm", "font:arimo_regular.ttf; size:30; color: blue; valign:bottom; halign:left;", 145, 100, 100, 45)
DME_grp=group_add(txt_Dis_NM,txt_Dis_NM_legend)
visible(DME_grp,true)
function gps_wp_callback (WPnextID, DISnextWP)
txt_set(txt_next_WP, WPnextID)
DISnextWP = DISnextWP/1852
txt_set(txt_Dis_NM, string.format("%0.1f", DISnextWP))
end
gps_wp_callback('WAYPOINT',852)
txt_style(txt_Dis_NM,"color: green;")
Last edited by JackZ on Thu Jun 09, 2022 4:56 pm, edited 4 times in total.
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ
Re: Changing font size in string.format
So simple using halign, don't know why I didn't think of that, maybe it was too late in the evening.JackZ wrote: ↑Thu Jun 09, 2022 4:37 pm here's a simple code based on yours for you to try
Notice the use of halign hereimage.pngCode: Select all
txt_next_WP=txt_add("XXXXX", "font:arimo_regular.ttf; size:50; color: red;valign:bottom;", 50, 50, 300, 50) txt_Dis_NM=txt_add("XXX", "font:arimo_regular.ttf; size:50; color: red; valign:bottom; halign:right;", 50, 100, 95, 50) txt_Dis_NM_legend=txt_add("Nm", "font:arimo_regular.ttf; size:30; color: blue; valign:bottom; halign:left;", 145, 100, 100, 45) DME_grp=group_add(txt_Dis_NM,txt_Dis_NM_legend) visible(DME_grp,true) function gps_wp_callback (WPnextID, DISnextWP) txt_set(txt_next_WP, WPnextID) DISnextWP = DISnextWP/1852 txt_set(txt_Dis_NM, string.format("%0.1f", DISnextWP)) end gps_wp_callback('WAYPOINT',852) txt_style(txt_Dis_NM,"color: green;")
The HSI is nearly complete now onto teaching myself multi-page instruments
Re: Changing font size in string.format
You're welcome....
My YouTube Chanel on the A320 (Real SOPs by an Airline Pilot IRL):
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ
https://www.youtube.com/playlist?list=P ... 0Q6SBASRqJ