How to change font properties in VB.Net 2010 - visual-studio-2010

So I have been using this snippet of code to change font properties
Me.lblOutPut.Font = New Font("Times New Roman", 22)
However, I have options inside my program to change the font size and font type, and if I have to change the font size, for example, I would have to specify the font type as well in the code. Instead of going this route, is there a way to create variables which can dynamically change the font size and style?
Example, because I think I haven't made myself clear enough:
User clicks button which changes font size from 12 to 16
Me.lblOutPut.Font = New Font("Times New Roman", 16)
User clicks button which sets font type to Arial
Me.lblOutPut.Font = New Font("Arial", 12)
How do I make it so that the font size does not change, but the font type does?

I think you need something like this:
Private Function setFont(myFont As Font, Optional fontFamily As String = "", Optional fontSize As Single = 0) As Font
If fontFamily = "" Then
fontFamily = myFont.FontFamily.ToString()
End If
If fontSize = 0 Then
fontSize = myFont.Size
End If
Return New Font(fontFamily, fontSize)
End Function
That you can use it like this:
' To change both FontFamily And Size
Me.lblOutPut.Font = setFont(Me.lblOutPut.Font, "Times New Roman", 16)
' To change only FontFamily
Me.lblOutPut.Font = setFont(Me.lblOutPut.Font, "Times New Roman", 0)
' Or
Me.lblOutPut.Font = setFont(Me.lblOutPut.Font, "Times New Roman")
' To change only Size
Me.lblOutPut.Font = setFont(Me.lblOutPut.Font, "", 12)

Related

Heroku Not Recognizing Rmagick Font

My Heroku app doesn't appear to want to recognize ANY kind of rmagick font family. In the following situation I would expect the font to be Times New Roman, but it is instead some system default. I've tried changing to Helvetica, and it's the same result - generic looking system font of some sort.
canvas = Magick::Image.read("caption:#{#statement.text}"){
self.size = "300x300"
self.colorspace = RGBColorspace
self.background_color = 'white'
self.font = "TimesNewRoman"
# self.font = "Helvetica"
self.gravity = CenterGravity
self.pointsize = 26
}.first
I've run identify -list font and observed that both TimesNewRoman and Helvetica are recognized by the system, but my image refuses to use them.
Bonus context: this is for the preview image in an og:image meta tag for display in Messages/Facebook Messager/etc. If I futz with the font family and display the image directly onto an html page there's no problem and it uses the appropriate font.
Per comment in the chain above:
Wowwwwwwwwww...apparently it's as easy as adding a .fonts folder to the root of your Heroku app and then moving your font into there - once you do that you can just reference the font directly when setting it onto ImageMagick...
So...yeah.
.fonts
| - "SF-Pro-Text-Light.otf
| - "SF-Pro-Text-Regular.otf
and
canvas = Magick::Image.read("caption:#{#statement.text}"){
self.size = "300x300"
self.colorspace = RGBColorspace
self.background_color = 'white'
self.font = "SF-Pro-Text-Light"
self.gravity = CenterGravity
self.pointsize = 26
}.first

How to add euro sign to UI.Window Text?

I'm trying to display a EUR currency amount to a UI.Window Text, so I try like this
var UI = require('ui');
var Vector2 = require('vector2');
var window = new UI.Window();
// Create TimeText
var euro = new UI.Text({
position: new Vector2(0, 80),
size: new Vector2(144, 30),
text: '€ 245',
font: 'gothic-14-bold'
});
window.add(euro);
While it's parsed correctly (console.log() of it displays € 245), but the euro sign is not displayed on the Pebble. So I tried to workaround like this
text: "\u20AC 245",
but this also fails. How can I display currency symbols correctly?
It seems that native Pebble fonts have a narrowed set of characters. But including images (or maybe embedding fonts?) are adjuvant workarounds.

Win7: Set Custom Text Size changes position of button's image

Good day all! I have a very tricky for me question.
In my application I have button with image inside. All properties of this button:
Me.cmdSelectAll.BackColor = System.Drawing.SystemColors.Control
Me.cmdSelectAll.Image = CType(resources.GetObject("cmdSelectAll.BackgroundImage"), System.Drawing.Image)
Me.cmdSelectAll.ImageAlign = Drawing.ContentAlignment.BottomRight
Me.cmdSelectAll.Cursor = System.Windows.Forms.Cursors.Default
Me.cmdSelectAll.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.cmdSelectAll.ForeColor = System.Drawing.SystemColors.ControlText
Me.cmdSelectAll.Location = New System.Drawing.Point(0, 282)
Me.cmdSelectAll.Name = "cmdSelectAll"
Me.cmdSelectAll.Padding = New System.Windows.Forms.Padding(0, 0, 0, 0)
Me.cmdSelectAll.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.cmdSelectAll.Size = New System.Drawing.Size(22, 22)
Me.cmdSelectAll.TabIndex = 11
Me.cmdSelectAll.TabStop = False
Me.ToolTip1.SetToolTip(Me.cmdSelectAll, "Select All Channels")
Me.cmdSelectAll.UseVisualStyleBackColor = False
When I run it with default text size of win7, the image appears in the center, it's all ok. But when I set some custom value of text size (115%) my image suddenly goes more right and down. It occurs with all of my button's images. Could you please answer me why does this happen and how can i fix this issue? Thanks

Set font and font size in R Console programmatically?

Is it possible to set the console font and font size, as I would with "Edit->GUI preferences", programmatically? How would a function for this look like? I am on windows.
On Windows (at least), the $R_HOME/etc/Rconsole config file sets many optional parameters for the console and pager. Here's the section that you could hand-edit to change the default font and font size:
## Font.
# Please use only fixed width font.
# If font=FixedFont the system fixed font is used; in this case
# points and style are ignored. If font begins with "TT ", only
# True Type fonts are searched for.
font = TT Courier New
points = 10
style = normal # Style can be normal, bold, italic
To change the values from the command line of an active R session, you could use the loadRconsole() function. It reads in a text file containing directives of the form shown above, which will overwrite the values read from Rconsole when R was launched. Here's an example:
temp <- tempfile()
cat("points = 13\n", file = temp)
cat("style = italic\n", file = temp, append = TRUE)
loadRconsole(file = temp)
## And then, to reset to the defaults:
loadRconsole(file = file.path(R.home(), "etc/Rconsole"))

Styling richtextbox in windows phone 7 from code

So I want to style richtextbox text from code, but I don't know how. There are two variables in the text, and I want the second one to have the accentcolor, and 2pt bigger fonts.
If you look at the MSDN site you can find out all the different properties the RichTextBox has.
Some stuff of interest
FontFamily
FontSize
Font Style
Foreground
Background
One way is to do it as in the below code
Run r1 = new Run();
r1.Text = "this is through ";
r1.FontSize = 18.0;
r1.FontStyle = FontStyles.Italic;
//r.Foreground=Brush.
Run r2 = new Run();
r2.Text = "code";
r2.FontWeight = FontWeights.ExtraBold;
r2.Foreground= new SolidColorBrush(Colors.Red);
Paragraph p = new Paragraph();
p.Inlines.Add(r1);
p.Inlines.Add(r2);
richTextBox1.Blocks.Add(p);

Resources