Log in

View Full Version : Subtitle Code in Avisynth will output Bold Font defualt,how to output unbold font?


cancandodo
14th May 2023, 14:19
Subtitle Code in Avisynth will output Bold Font defualt,how to output unbold font?


Cilp.Subtitle("Hello", font="Arial",first_frame=0, last_frame=999, x=0,y=0,size=72, text_color=$FFFFFF, lsp=0)

this codes output Text will be show as Bold fonts defualt
i don't know how to change to unbold font?

poisondeathray
1st June 2023, 17:34
It should be font="Arial Regular", but result looks like Courier to me

font="Arial Black", font="Arial Italic" , font="Arial Bold Italic" all work, but not "Arial Regular" for some reason. Not sure why

StainlessS
4th June 2023, 02:23
but not "Arial Regular" for some reason.
Not far off PDR :)

BlankClip()
Subtitle("Hellow World",Font = "Arial",Size=64)
Subtitle("Hellow World",Font = "Arial-Regular",Size=64,Y=80)

https://i.postimg.cc/CBsPRqdg/font-00.jpg (https://postimg.cc/CBsPRqdg)

EDIT: NO, that aint right either, change to eg "Arial-RegularZZZZZZ" and same result.
(I looked it up in google and somewhere it said "Arial-Regular", but it aint right)

BlankClip()
Subtitle("Hellow World",Font = "Arial",Size=64)
Subtitle("Hellow World",Font = "arial bold",Size=64,Y=80)

same
https://i.postimg.cc/njYCDHv7/font-00.jpg (https://postimg.cc/njYCDHv7)

Windows 10 font list:
https://learn.microsoft.com/en-us/typography/fonts/windows_10_font_list
It aint there. [well not as arial regular]
Does not seem to be in XP either [some XP available fonts went missing in later years, I think].

Does not seem to be in W10 Features On Demand
https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/features-on-demand-v2--capabilities?view=windows-11

But there is a Downloadable version available.
https://www.dafontfree.net/arial-regular/f169067.htm

EDIT:
Damn, its there in my Control Panel Fonts whatsit, [clickMe]
https://i.postimg.cc/gwsDHPq9/Arial-Regular.jpg (https://postimg.cc/gwsDHPq9)

qyot27
4th June 2023, 06:01
You can't.

https://github.com/AviSynth/AviSynthPlus/blob/master/avs_core/filters/source.cpp#LL496C1-L496C1
extern bool GetTextBoundingBox(const char* text, const char* fontname, int size, bool bold, bool italic, int align, int* width, int* height);

https://github.com/AviSynth/AviSynthPlus/blob/master/avs_core/filters/source.cpp#LL518C5-L518C108
GetTextBoundingBox(message, "Arial", size, true, false, TA_TOP | TA_CENTER, &text_width, &text_height);

Now for the fun part. That second one, where the font and sizing and what-all is actually set? That part has remained untouched for nearly 20 years - and that commit on November 27th 2003 was just moving the file itself around, past which there is no commit history for source.cpp. Subtitle() has been hardcoded to only output Bold text for longer than the commit history of the file where it's defined. It may well reach back into the 2.0 or 1.x days, but the file move occurred about a week after the version was bumped to 2.5.4.

DTL
4th June 2023, 06:49
As I remember in Win font rasterizing API exist also 'font weight' param - but for most of fonts it do nothing (or simply select between standard and bold). So font must support different 'weight' drawing data or rendered sets ?

From some branch of win-API docs : https://learn.microsoft.com/en-us/dotnet/api/system.windows.fontweights?view=windowsdesktop-7.0

A font weight describes the relative weight of a font, in terms of the lightness or heaviness of the strokes. Weight differences are generally differentiated by an increased stroke or thickness that is associated with a given character in a font, as compared to a "normal" character from that same font.

The FontWeights values correspond to the usWeightClass definition in the OpenType specification. The usWeightClass represents an integer value between 1 and 999. Lower values indicate lighter weights; higher values indicate heavier weights.
Font weight usWeightClass
Thin 100
ExtraLight

UltraLight 200
Light 300
Normal

Regular 400
Medium 500
DemiBold

SemiBold 600
Bold 700
ExtraBold

UltraBold 800
Black

Heavy 900
ExtraBlack

UltraBlack 950

Also about production fonts rasters for moving pictures domain (not dual tone Black and White font original domain) - the conditioning of glyphs raster in scene linear light and in system transfer domain also changes view (visible width/contrast/thickness) of small (thin) parts of glyphs significantly.

" Subtitle() has been hardcoded to only output Bold text"

Not all documented Win API actually working in all documented control paths. So old developers may select simply most frequently working way. General idea of AVS developers looks like keep itself even today - let it be simple in features but easy to support and work in most use cases.

pinterf
5th June 2023, 15:47
Due to the public demand :), bold and italic parameters (boolean) were introduced (for "Info" as well). When Subtitle acts as "Text" (non-windows systems), "italic" parameter is simply ignored. Font name must be the same ("Arial" for example) and setting bold=false, italic=true will differentiate.
Other filters with less customization option (Compare, ShowSMTPE, ...) have no such parameter, they keep working on with the defaults.

Reel.Deel
5th June 2023, 22:17
Very nice pinterf! :)

Any possibility of adding a parameter to disable anti-aliasing also? There was some demand for it in this thread: https://forum.doom9.org/showthread.php?t=184627

I know SubtitleEx (http://avisynth.nl/index.php/SubtitleEx) can do it, which uses Subtitle as the rendering engine.

pinterf
7th June 2023, 15:57
Very nice pinterf! :)

Any possibility of adding a parameter to disable anti-aliasing also? There was some demand for it in this thread: https://forum.doom9.org/showthread.php?t=184627

I know SubtitleEx (http://avisynth.nl/index.php/SubtitleEx) can do it, which uses Subtitle as the rendering engine.
O.K., noaa parameter was implemented in SubTitle.
All three new parameters (bold/italic/noaa) were added to some debug filters: ShowSMTPE, ShowFrameNumber, ShowCRC32, ShowTime
Check readme_history.txt