Loading fonts in Python/Pillow on a Mac - python-imaging-library
The Pillow ImageFont documentation has a few examples of using different fonts, but they don't work "out of the box" on a Mac. It's probably not too hard to figure out where my system fonts are located, but I'm lazy and would like a simple example that I can just edit.
So: how can I use Pillow on a Mac to write some text in a different font and size from the default?
Ok, "Lazy One" ;-) Here is an example:
from PIL import Image, ImageFont, ImageDraw
# Make a red canvas and get a drawing context to it
img = Image.new(mode='RGB', size=(500, 200), color=(255,0,0))
draw = ImageDraw.Draw(img)
# Get a "Chalkduster" TTF
chalk = ImageFont.truetype("Chalkduster.ttf",16)
# Get a "Keyboard" TTF
kbd = ImageFont.truetype("Keyboard.ttf",26)
# Make example for Lazy One - showing how to colour cyan too
draw.text((40,40),"Keyboard",font=kbd, fill=(0,255,255))
# And another
draw.text((20,140),"Chalkduster",font=chalk)
img.save("test.png")
If you want a list of all the TTF fonts on your system, you can look in both:
/System/Library/Fonts, and
/Library/Fonts
And, if you are very lazy, you can check in both at the same time from Terminal:
find {/System,}/Library/Fonts -name \*ttf
Sample Output
/System/Library/Fonts/SFNSDisplay.ttf
/System/Library/Fonts/Symbol.ttf
/System/Library/Fonts/ZapfDingbats.ttf
/System/Library/Fonts/Apple Braille.ttf
/System/Library/Fonts/SFNSText.ttf
/System/Library/Fonts/Apple Braille Outline 6 Dot.ttf
/System/Library/Fonts/Apple Braille Pinpoint 6 Dot.ttf
/System/Library/Fonts/Apple Symbols.ttf
/System/Library/Fonts/SFNSTextItalic.ttf
/System/Library/Fonts/SFNSRounded.ttf
/System/Library/Fonts/Apple Braille Pinpoint 8 Dot.ttf
/System/Library/Fonts/Keyboard.ttf
/System/Library/Fonts/Apple Braille Outline 8 Dot.ttf
/Library/Fonts/Webdings.ttf
/Library/Fonts/Zapfino.ttf
/Library/Fonts/Trebuchet MS Italic.ttf
/Library/Fonts/Georgia.ttf
/Library/Fonts/Verdana Bold.ttf
/Library/Fonts/Bodoni 72 Smallcaps Book.ttf
/Library/Fonts/Times New Roman Bold Italic.ttf
/Library/Fonts/Silom.ttf
/Library/Fonts/Verdana Italic.ttf
/Library/Fonts/Times New Roman Italic.ttf
/Library/Fonts/Bradley Hand Bold.ttf
/Library/Fonts/Arial Narrow Italic.ttf
/Library/Fonts/AppleGothic.ttf
/Library/Fonts/DIN Condensed Bold.ttf
/Library/Fonts/Farisi.ttf
/Library/Fonts/Arial Bold.ttf
/Library/Fonts/Trebuchet MS.ttf
/Library/Fonts/Mishafi.ttf
/Library/Fonts/Trattatello.ttf
/Library/Fonts/BigCaslon.ttf
/Library/Fonts/Courier New Bold.ttf
/Library/Fonts/NISC18030.ttf
/Library/Fonts/Lao Sangam MN.ttf
/Library/Fonts/Luminari.ttf
/Library/Fonts/Times New Roman.ttf
/Library/Fonts/Brush Script.ttf
/Library/Fonts/Georgia Italic.ttf
/Library/Fonts/Courier New Italic.ttf
/Library/Fonts/Arial Unicode.ttf
/Library/Fonts/Chalkduster.ttf
/Library/Fonts/Apple Chancery.ttf
/Library/Fonts/AppleMyungjo.ttf
/Library/Fonts/Arial Narrow Bold Italic.ttf
/Library/Fonts/Arial Narrow.ttf
/Library/Fonts/Courier New.ttf
/Library/Fonts/Wingdings 3.ttf
/Library/Fonts/Wingdings 2.ttf
/Library/Fonts/Hoefler Text Ornaments.ttf
/Library/Fonts/Bodoni Ornaments.ttf
/Library/Fonts/Skia.ttf
/Library/Fonts/Trebuchet MS Bold Italic.ttf
/Library/Fonts/Impact.ttf
/Library/Fonts/Kokonor.ttf
/Library/Fonts/Tahoma Bold.ttf
/Library/Fonts/Arial.ttf
/Library/Fonts/Diwan Thuluth.ttf
/Library/Fonts/Ayuthaya.ttf
/Library/Fonts/Khmer Sangam MN.ttf
/Library/Fonts/Trebuchet MS Bold.ttf
/Library/Fonts/Arial Black.ttf
/Library/Fonts/Courier New Bold Italic.ttf
/Library/Fonts/Comic Sans MS.ttf
/Library/Fonts/DIN Alternate Bold.ttf
/Library/Fonts/Wingdings.ttf
/Library/Fonts/Sathu.ttf
/Library/Fonts/Arial Bold Italic.ttf
/Library/Fonts/Tahoma.ttf
/Library/Fonts/PlantagenetCherokee.ttf
/Library/Fonts/Georgia Bold.ttf
/Library/Fonts/Verdana Bold Italic.ttf
/Library/Fonts/Microsoft Sans Serif.ttf
/Library/Fonts/Georgia Bold Italic.ttf
/Library/Fonts/Arial Rounded Bold.ttf
/Library/Fonts/Times New Roman Bold.ttf
/Library/Fonts/Krungthep.ttf
/Library/Fonts/Gurmukhi.ttf
/Library/Fonts/Andale Mono.ttf
/Library/Fonts/Mishafi Gold.ttf
/Library/Fonts/Herculanum.ttf
/Library/Fonts/Comic Sans MS Bold.ttf
/Library/Fonts/Arial Italic.ttf
/Library/Fonts/Verdana.ttf
/Library/Fonts/Arial Narrow Bold.ttf
Related
tFPDF unicode characters in Arial bold
I'm trying to create PDF by FPDF (tFPDF) but I still can't create output with correct charset. Problem is in czech letters: ě,š,č,ř,ž,ů etc... Source: <?php require_once('../tfpdf/tfpdf.php'); define("_SYSTEM_TTFONTS", "C:/Windows/Fonts/"); $pdf = new tFPDF('P','mm','A5'); $pdf->SetMargins(8,5,8); $pdf->AddPage(); // Pracoviště $pdf->SetFont('Arial', '', 10); $pdf->Cell(25,12,'Pracoviště:','L',0); $pdf->Output(); ?> I need to write "Pracoviště:" but output is "PracoviÅ¡tÄ›:". For regular Arial I solved it by: $pdf->AddFont('Arial','','arial.ttf',true); but it doesen't work for bold. I tried: $pdf->AddFont('Arial','','arial.ttf',true); // Arial $pdf->AddFont('Arial','B','arialbd.ttf',true); // Arial Bold $pdf->SetFont('Arial', '', 10); $pdf->Cell(25,12,'Pracoviště:'); // output: Pracoviště: $pdf->SetFont('Arial', 'B', 10); $pdf->Cell(25,12,'Pracoviště:'); // output: PracoviÅ¡tÄ›: Interestingly if I use Arial Black file, it works, but it's not font what I need. $pdf->AddFont('Arial','','arial.ttf',true); // Arial $pdf->AddFont('Arial','B','ariblk.ttf',true); // Arial Black $pdf->SetFont('Arial', '', 10); $pdf->Cell(25,12,'Pracoviště:'); // output: Pracoviště: $pdf->SetFont('Arial', 'B', 10); $pdf->Cell(25,12,'Pracoviště:'); // output: Pracoviště: - but Arial Black font, I need Arial Bold Why Arial works, Arial Black works too and Arial Bold doesn't work? How to solve it?
sas horizontal bar chart-Making labels same size
I'm using a macro to generate many similar horizontal bar charts. The chart width changes according to the labels (on the vertical axis) length. How I can make all the charts the same width causing the labels to wrap automatically to adjust? data my_annoDetailedChart&i; set FinalDim&i; xsys='2'; ysys='2'; hsys='3'; when='a'; group=itemname; midpoint=entity; x=score; function='label'; position='>'; color='grayaa'; size=1.5; text=" "||trim(left(put(score,comma5.2))); goptions device=png; goptions xpixels=700 ypixels=450; goptions noborder; goptions cback=white; goptions gunit=pct ftitle="albany amt/bold" ftext="albany amt" hsize=6.5 vsize= 7.6 inches htitle=4.1 htext=1.5 ctext=gray44;************************************************************************************************************; *---Indicators---------------------------------------------------------------------------------------------; pattern1 v=solid c=navy; /* blue */ pattern2 v=solid c=lightgray; /* green */ pattern1 v=solid c=navy; /* blue */ pattern2 v=solid c=lightgray; /* green */ axis1 SPLIT="*" label=none order=(1 to 5 by .5) minor=none offset=(0,0) color=graydd major=(color=gray44) value=(color=gray44); axis2 SPLIT="*" label=none value=none ; axis3 label=none offset=(3,3);* order=( &KOko); legend1 position=(bottom right inside) mode=share label=none shape=bar(.15in,.15in) offset=(-1,-0.1); proc gchart data=FinalDim&i anno=my_annoDetailedChart&i; hbar entity / discrete type=sum sumvar=Score nostat subgroup=entity group=itemname space=0 gspace=1 raxis=axis1 maxis=axis2 gaxis=axis3 autoref legend=legend1 clipref ; title color=navy h=6 font="Times New Roman" "&Dimension";
PdfReaderContentParser.ProcessContent returns whitespace for clear text
I'd like to parse a pdf for texts containing both, binary and clear text data. When I try to do it with PdfReaderContentParser the GetResultantText method returns the right texts for the binary content but whitespaces for the clear text content. Here is the code I use: byte[] binaryPdf = File.ReadAllBytes(this.fileName); reader = new PdfReader(binaryPdf); PdfReaderContentParser parser = new PdfReaderContentParser(reader); for (int i = 1; i <= reader.NumberOfPages; i++) { SimpleTextExtractionStrategy simpleStragety = parser.ProcessContent(i, new SimpleTextExtractionStrategy()); string contentText = simpleStragety.GetResultantText(); // Do something with the contentText // ... } Any idea how to get all content?
Overview In a comment the OP clarified which texts he was missing in his extracted text: Basically for all descriptions on the left-hand side (e.g. Lifting moment) I get whitespaces instead of the actual text. The reason for this is fairly simple: In the page content there are only spaces (if anything at all) on most of the left side. The labels you see actually are read-only form fields. For example the "Lifting moment" is the value of the form field 13B141032. If you want text extraction to include these fields, too, you should consider flattening the document in a first step (moving the field appearances into the regular page content stream) and extracting text from this flattened document. Document analysis It looks like the major part of the internationalization of the specification labels has been done using form fields. For an overview I separated the original document into its regular page content and the form fields There indeed are several strings of spaces in the page content under the form fields. I would assume that there once was an earlier version of that document (or a template for it) which contained those labels (maybe in only one language or probably two) as page content. Then there was a task of more dynamic internationalization, so someone replaced the existing labels in the page content by spaces and added new internationalized labels as read-only form-fields, probably because form fields are easier to manipulate. Considering that the original labels seem to have been replaced by an equal number of spaces, though, one might speculate that there even is another program manipulating the page stream of this and similar documents at hard coded offsets, and to not break this program in the course of internationalization the actual labels had to be created outside the page content. Stranger things have happened... Flatten and extract As mentioned above, if you want text extraction to include these fields, too, you should consider flattening the document in a first step (moving the field appearances into the regular page content stream) and extracting text from this flattened document. This can be done like this: [Test] public void ExtractFlattenedTextTestSeeb() { FileInfo file = new FileInfo(#"PATH_TO_FILE\41851208.pdf"); Console.Out.Write("41851208.pdf, flattened before extraction\n\n"); using (MemoryStream memStream = new MemoryStream()) { using (PdfReader readerOrig = new PdfReader(file.FullName)) using (PdfStamper stamper = new PdfStamper(readerOrig, memStream)) { stamper.Writer.CloseStream = false; stamper.FormFlattening = true; } memStream.Position = 0; using (PdfReader readerFlat = new PdfReader(memStream)) { PdfReaderContentParser parser = new PdfReaderContentParser(readerFlat); for (int i = 1; i <= readerFlat.NumberOfPages; i++) { SimpleTextExtractionStrategy simpleStragety = parser.ProcessContent(i, new SimpleTextExtractionStrategy()); string contentText = simpleStragety.GetResultantText(); Console.Write("Page {0}:\n\n{1}\n\n", i, contentText); } } } } The result StandardOutput: 41851208.pdf, flattened before extraction Page 1: 90–120 l/min (23.8–31.7 US gal./min) 60 kg (132 lbs) 115 kg (254 lbs) 350 l (92.5 US gal.) 100 kg 105 kg (220 lbs) (231 kg) 100 kg (220 lbs) 250 l 300 l (66.0 US gal.) (79.3 US gal.) 90 kg (198 lbs) 180 l (47.6 US gal.) 5305kg (11695 lbs) 5265kg (11607 lbs) 5395kg (11894 lbs) 5205kg (11475 lbs) 5010kg (11045 lbs) 4780kg (10538 lbs) 4470kg (9854 lbs) 4190kg (9237 lbs) 3930kg (8664 lbs) 5215kg (11497 lbs) 5045kg (11122 lbs) 4860kg (10714 lbs) 4650kg (10251 lbs) 4350kg (9590 lbs) 4100kg (9039 lbs) 3850kg (8488 lbs) 25.2 m (82’ 8") 23.2 m (76’ 1") 21.0 m (68’ 11") 18.7 m (61’ 4") 16.4 m (53’ 10") 14.1 m (46’ 3") 11.8 m (38’ 9") 9.7 m (31’ 10") 7.7 m (25’ 3") 36.5 MPa (365 bar) (5293 psi) endlos endless sans finite 25.2 m 31.2 m (82’ 8") (102’ 4") 21.0 m (68’ 11") 14900kg (32848 lbs) 403.2 kNm (41.1 mt) (297270 ft.lbs) 49.1 kNm (5.0 mt) PK 42002–SH A–G (36210 ft.lbs) 37.3 kNm (3.8 mt) PK 42002–SH A–C (27510 ft.lbs) 1GETR 2GETR PK 42002–SH A – C KT250 KT300 KT350 KT180 2GETR STZY +V1 +V2 +2/4 7(F) 8(G) 6(E) 5(D) 4(C) 3(B) 2(A) +V1 +V2 (S410–SK–D) DTS410SHC/03 0100 11/2010 PK 42002–SH Type Model Modell Page Page Seite Chapitre Chapter Kapitel Edition Edition Ausgabe Öltank Mehrgewicht: Alle Gewichtsangaben ohne Aufbauzubehör,Zusatzgeräte und Öl. Hydr. Ausschübe: Max. Reichweite + Fly-Jib: Max. Reichweite: Fördermenge der Pumpe: Betriebsdruck: Schwenkmoment: Schwenkbereich: Max. Reichweite: Max. hydraulische Reichweite: Max. Hubkraft: Max. Hubmoment: Gewicht +V ohne 2/4 Krangewicht (R3X,STZS): Technische Daten Konstruktionsänderungen vorbehalten, fertigungstechn. Toleranzen müssen berücksichtigt werden. Oil tank Excess weight: All weights given without assembly accessory,additional devices and oil. Hydr. boom extensions: Max. outreach + Fly-Jib: Max. outreach: Pump capacity: Operating pressure: Slewing torque: Slewing angle: Max. outreach: Max. hydraulic outreach: Max. lifting capacity: Lifting moment: Weight +V without 2/4 Crane weight (R3X,STZS): Specifications Subject to change, production tolerances have to be taken into account. Réservoir Excessif poids: Tous les poids sans huile ni accessoire de montage ni appareils accessoires Extensions hydrauliques: Portee maximale + Fly-Jib: Max. portee: Debit de pompe: Pression d' utilisation: Couple de rotation: Angle de rotation: Max. portee: Portee hydraulique maximale: Capacite maxi de levage: Couple de levage: Poids +V sans 2/4 Poids grue (R3X,STZS): Données Techniques Sous reserve de modifications de conception. Les tolerances relatives a la technique de production doivent etre prises en consideration. As you see, "Lifting moment" and all the other missing labels are there now.
Switch between multiple functions MATLAB
So I have an m. file script that contains 2 functions. The first one (that's loaded when I run the script) and the second. Each of them has a different GUI setup and different text in text boxes (sorry for tautology). My program is about calculating stuff using economic formulas, and the final version of the program is going to have about 50 formulas in it. AND I don't want to make 50 separate scripts for each formula. What I want is to be able to switch between formulas inside one script. So I made a specific push button for that purpose (code below) but when I press it nothing happens. Can someone who's experienced enough tell me what did I do wrong? (I'm new to MATLAB). Let me know if more information is needed, or the question is not clear enough. Thanks in advance! uicontrol('Style','pushbutton','Position',[136,88,194,27],'String','Next formula','FontSize',10,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685],'CallBack',#SecondScript); Here's the whole script: function FirstScript clc clear close all global ZatratyNaSozdanieProgProdukta hEditZzpspp hEditZmvspp hEditZobsh ScreenSize = get(0,'ScreenSize'); set ( 0, 'DefaultFigureColor', [0.23137255012989 0.443137258291245 0.337254911661148] ) hFig = figure('Visible','off','Position',[ScreenSize(3)/2,ScreenSize(4)/2,550,450]); uicontrol('Style','Pushbutton','Position',[371,136,98,27],'String','Рассчитать','FontSize',10,'FontName','MS Reference Sans Serif','Callback',#CalculateCallback,'BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); uicontrol('Style','pushbutton','Position',[136,88,194,27],'String','Next formula','FontSize',10,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685],'CallBack',#SecondScript); axes('units','pixels','position',[20 100 200 24],'visible','off'); message = sprintf('Формула определения затрат на\nсоздание программного продукта:\n \nЗ^З^П_С_П_П+З^М^В_С_П_П+З_О_Б_Щ'); text(0,4.6,message,'interpreter','tex','Position',[1.18 8.64166666666667 0],'HorizontalAlignment','center','FontSize',12,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); axes('units','pixels','position',[20 100 200 24],'visible','off'); hTextZzpspp = text(0,4.6,'З^З^П_С_П_П','interpreter','tex','Position',[0.55 4.14166666666666 0],'FontSize',12,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); hEditZzpspp = uicontrol('Style','Edit','Position',[117,150,72,25],'String','','FontSize',10,'FontName','MS Reference Sans Serif'); axes('units','pixels','position',[20 100 200 24],'visible','off'); hTextZmvspp = text(0,4.6,'З^М^В_С_П_П','interpreter','tex','Position',[0.935 4.14166666666666 0],'FontSize',12,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); hEditZmvspp = uicontrol('Style','Edit','Position',[195,150,72,25],'String','','FontSize',10,'FontName','MS Reference Sans Serif'); axes('units','pixels','position',[20 100 200 24],'visible','off'); hTextZobsh = text(0,4.6,'З_О_Б_Щ','interpreter','tex','Position',[1.32 4.05833333333332 0],'FontSize',12,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); hEditZobsh = uicontrol('Style','Edit','Position',[274,150,72,25],'String','','FontSize',10,'FontName','MS Reference Sans Serif'); uicontrol('Style','Text','Position',[370,191,100,29],'String','Результат:','FontSize',12,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); ZatratyNaSozdanieProgProdukta = uicontrol('Style','Text','Position',[370,168,100,23],'String','','FontSize',10,'FontName','MS Reference Sans Serif'); set(hFig,'Visible','on') function CalculateCallback(~,~) Zzpspp = str2double(get(hEditZzpspp,'String')); Zmvspp = str2double(get(hEditZmvspp,'String')); Zobsh = str2double(get(hEditZobsh,'String')); Calculation = Zzpspp+Zmvspp+Zobsh; set(ZatratyNaSozdanieProgProdukta,'String',sprintf('%0.2f',Calculation)); end end function SecondScript clc clear close all global RashodyNaOplatuTrudaRazrabotchikaProgrammy hEditZosnzp hEditZdopzp hEditZotchzp ScreenSize = get(0,'ScreenSize'); set ( 0, 'DefaultFigureColor', [0.23137255012989 0.443137258291245 0.337254911661148] ) hFig = figure('Visible','off','Position',[ScreenSize(3)/2,ScreenSize(4)/2,550,450]); uicontrol('Style','Pushbutton','Position',[371,136,98,27],'String','Рассчитать','FontSize',10,'FontName','MS Reference Sans Serif','Callback',#CalculateCallback,'BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); axes('units','pixels','position',[20 100 200 24],'visible','off'); message = sprintf('Формула определения расходов на\nоплату труда разработчика программы:\n \nЗ^З^П_С_П_П+З^М^В_С_П_П+З_О_Б_Щ'); text(0,4.6,message,'interpreter','tex','Position',[1.18 8.64166666666667 0],'HorizontalAlignment','center','FontSize',12,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); axes('units','pixels','position',[20 100 200 24],'visible','off'); hTextZosnzp = text(0,4.6,'З^З^П_С_П_П','interpreter','tex','Position',[0.55 4.14166666666666 0],'FontSize',12,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); hEditZosnzp = uicontrol('Style','Edit','Position',[117,150,72,25],'String','','FontSize',10,'FontName','MS Reference Sans Serif'); axes('units','pixels','position',[20 100 200 24],'visible','off'); hTextZdopzp = text(0,4.6,'З^М^В_С_П_П','interpreter','tex','Position',[0.935 4.14166666666666 0],'FontSize',12,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); hEditZdopzp = uicontrol('Style','Edit','Position',[195,150,72,25],'String','','FontSize',10,'FontName','MS Reference Sans Serif'); axes('units','pixels','position',[20 100 200 24],'visible','off'); hTextZotchzp = text(0,4.6,'З_О_Б_Щ','interpreter','tex','Position',[1.32 4.05833333333332 0],'FontSize',12,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); hEditZotchzp = uicontrol('Style','Edit','Position',[274,150,72,25],'String','','FontSize',10,'FontName','MS Reference Sans Serif'); uicontrol('Style','Text','Position',[370,191,100,29],'String','Результат:','FontSize',12,'FontName','MS Reference Sans Serif','BackgroundColor',[0.756862759590149 0.866666674613953 0.776470601558685]); RashodyNaOplatuTrudaRazrabotchikaProgrammy = uicontrol('Style','Text','Position',[370,168,100,23],'String','','FontSize',10,'FontName','MS Reference Sans Serif'); set(hFig,'Visible','on') function CalculateCallback(~,~) Zosnzp = str2double(get(hEditZosnzp,'String')); Zdopzp = str2double(get(hEditZdopzp,'String')); Zotchzp = str2double(get(hEditZotchzp,'String')); Calculation = Zosnzp+Zdopzp+Zotchzp; set(RashodyNaOplatuTrudaRazrabotchikaProgrammy,'String',sprintf('%0.2f',Calculation)); end end
I have a trick, although i myself find it not very good-looking: Assuming you put all of these functions inside a file myforms.m without any blank line. Then, at the beginning of your GUI, open and read your file: f1 = fopen('myforms.m'); alllines = textscan(f1, '%s', 'Delimiter', ''); fclose(f1); alllines{1} is now a cell array, and each element is one line from myforms.m. Now, when you want to switch to a formula, you need to know the line number of its section in myforms.m, for example starting from line 10, ending at line 15. Create a new file, i.e callme.m which should be called by your button, and write these lines to the file: f2 = fopen('callme.m', 'w'); for i = 10:15 fprintf(f2, '%s\n', alllines{1}{i}); end fclose(f2); Your callback function can then be #callme.
I've put source and eventdata in a set of parentheses directly after the function's name and it solved the problem! I can now easily switch between formulas as fast as I can push the button. Here's how my function's name looked like before: function SecondScript Here's how it looks now: function SecondScript(source,eventdata)
Issues with setting some different font for UILabel
I would like to set the font size and familyname to the titleLabel. //Helvetica Neue UltraLight [titleLabel setFont:[UIFont fontWithName:#"Helvetica Neue UltraLight" size:25.0f]]; This is not working. Kindly tell me what could be wrong? Any help will be appreciated?
the correct fontName is #"HelveticaNeue-UltraLight". use something like this to get a nicely formatted list of available font names: NSMutableString *str = [NSMutableString stringWithCapacity:1000]; for (NSString *familyName in [UIFont familyNames]) { [str appendFormat:#"%#\n", familyName]; for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) { [str appendFormat:#" %#\n", fontName]; } [str appendString:#"\n"]; } NSLog(#"%#", str); this is the current list for iOS5.1: Thonburi Thonburi-Bold Thonburi Snell Roundhand SnellRoundhand-Bold SnellRoundhand-Black SnellRoundhand Academy Engraved LET AcademyEngravedLetPlain Marker Felt MarkerFelt-Wide MarkerFelt-Thin Geeza Pro GeezaPro-Bold GeezaPro Arial Rounded MT Bold ArialRoundedMTBold Trebuchet MS TrebuchetMS TrebuchetMS-Bold TrebuchetMS-Italic Trebuchet-BoldItalic Arial Arial-BoldMT ArialMT Arial-ItalicMT Arial-BoldItalicMT Marion Marion-Regular Marion-Bold Marion-Italic Gurmukhi MN GurmukhiMN GurmukhiMN-Bold Malayalam Sangam MN MalayalamSangamMN-Bold MalayalamSangamMN Bradley Hand BradleyHandITCTT-Bold Kannada Sangam MN KannadaSangamMN KannadaSangamMN-Bold Bodoni 72 Oldstyle BodoniSvtyTwoOSITCTT-Book BodoniSvtyTwoOSITCTT-Bold BodoniSvtyTwoOSITCTT-BookIt Cochin Cochin Cochin-BoldItalic Cochin-Italic Cochin-Bold Sinhala Sangam MN SinhalaSangamMN SinhalaSangamMN-Bold Hiragino Kaku Gothic ProN HiraKakuProN-W6 HiraKakuProN-W3 Papyrus Papyrus-Condensed Papyrus Verdana Verdana Verdana-Bold Verdana-BoldItalic Verdana-Italic Zapf Dingbats ZapfDingbatsITC Courier Courier-Bold Courier Courier-BoldOblique Courier-Oblique Hoefler Text HoeflerText-Black HoeflerText-Italic HoeflerText-Regular HoeflerText-BlackItalic Euphemia UCAS EuphemiaUCAS-Bold EuphemiaUCAS EuphemiaUCAS-Italic Helvetica Helvetica-LightOblique Helvetica Helvetica-Oblique Helvetica-BoldOblique Helvetica-Bold Helvetica-Light Hiragino Mincho ProN HiraMinProN-W3 HiraMinProN-W6 Bodoni Ornaments BodoniOrnamentsITCTT Apple Color Emoji AppleColorEmoji Optima Optima-ExtraBlack Optima-Italic Optima-Regular Optima-BoldItalic Optima-Bold Gujarati Sangam MN GujaratiSangamMN GujaratiSangamMN-Bold Devanagari Sangam MN DevanagariSangamMN DevanagariSangamMN-Bold Times New Roman TimesNewRomanPS-ItalicMT TimesNewRomanPS-BoldMT TimesNewRomanPSMT TimesNewRomanPS-BoldItalicMT Kailasa Kailasa Kailasa-Bold Telugu Sangam MN TeluguSangamMN-Bold TeluguSangamMN Heiti SC STHeitiSC-Medium STHeitiSC-Light Apple SD Gothic Neo AppleSDGothicNeo-Bold AppleSDGothicNeo-Medium Futura Futura-Medium Futura-CondensedExtraBold Futura-CondensedMedium Futura-MediumItalic Bodoni 72 BodoniSvtyTwoITCTT-BookIta BodoniSvtyTwoITCTT-Book BodoniSvtyTwoITCTT-Bold Baskerville Baskerville-SemiBoldItalic Baskerville-Bold Baskerville-Italic Baskerville-BoldItalic Baskerville-SemiBold Baskerville Chalkboard SE ChalkboardSE-Regular ChalkboardSE-Bold ChalkboardSE-Light Heiti TC STHeitiTC-Medium STHeitiTC-Light Copperplate Copperplate Copperplate-Light Copperplate-Bold Party LET PartyLetPlain American Typewriter AmericanTypewriter-CondensedLight AmericanTypewriter-Light AmericanTypewriter-Bold AmericanTypewriter AmericanTypewriter-CondensedBold AmericanTypewriter-Condensed Bangla Sangam MN BanglaSangamMN-Bold BanglaSangamMN Noteworthy Noteworthy-Light Noteworthy-Bold Zapfino Zapfino Tamil Sangam MN TamilSangamMN TamilSangamMN-Bold DB LCD Temp DBLCDTempBlack Arial Hebrew ArialHebrew ArialHebrew-Bold Chalkduster Chalkduster Georgia Georgia-Italic Georgia-BoldItalic Georgia-Bold Georgia Helvetica Neue HelveticaNeue-Bold HelveticaNeue-CondensedBlack HelveticaNeue-Medium HelveticaNeue HelveticaNeue-Light HelveticaNeue-CondensedBold HelveticaNeue-LightItalic HelveticaNeue-UltraLightItalic HelveticaNeue-UltraLight HelveticaNeue-BoldItalic HelveticaNeue-Italic Gill Sans GillSans-LightItalic GillSans-BoldItalic GillSans-Italic GillSans GillSans-Bold GillSans-Light Palatino Palatino-Roman Palatino-Bold Palatino-BoldItalic Palatino-Italic Courier New CourierNewPSMT CourierNewPS-BoldMT CourierNewPS-BoldItalicMT CourierNewPS-ItalicMT Oriya Sangam MN OriyaSangamMN-Bold OriyaSangamMN Didot Didot-Italic Didot Didot-Bold Bodoni 72 Smallcaps BodoniSvtyTwoSCITCTT-Book
You use wrong font name, correct one will be: [titleLabel setFont:[UIFont fontWithName:#"HelveticaNeue-UltraLight" size:25.0f]]; You can see the list of all available font names for a given font family using +fontNamesForFamilyName: method in UIFont, e.g.: [UIFont fontNamesForFamilyName:#"Helvetica Neue"] Edit: Also mind that some fonts may not be present on all versions of iOS as Apple gradually adds (and sometimes probably removes) fonts from standard OS set. It appears that "HelveticaNeue-UltraLight" font present in OS starting 5.0 version. If you want to use it in older OS versions you'll need to embed it to you application - check for example this answer for details how to do that
Please see List of Fonts available in iOS and use font names according this...