PrivateFontCollection Quastion

A

al jones

Okay, I don't have headaches enough from my toy ... If I were to ty to load
several fontfiles into a PrivateFontCollection, how would I then select one
to use.

Let's say that I have a couple of fonts, uninstalled of course, in some
directory.

Creating the PrivateFontCollection is pretty self expanatory (or so it
seems) and then loading fonts into that collection also seems pretty
straight forward.

So let's for argument say that I create the collection, load a font that I
then want to immediately use in a RichTextBox (yep, back there) for a
sample of the font; then load another font and use it for a sample ... how
do I know which of the fonts in the collection is 'current' or how would I
set the last font as current [font = fontCollection(ubound)???]. Sorry, I
don't see how to use the fonts in the collection except from the examples
where the collection is walked one font at a time ....

Thanks //al
 
V

VJ

Looks like you need to maintain a list of Font's and identify at any point
which one are being used.. and You are on the write path by writing your own
private collection...which I am guessing you have implementing a Collection
Interface or IList Interface.. You could just add a Boolean value to this
PrivateFontCollection.. Expanding on the same line, you can write each
FontCollection item as its own class, and then add a Boolean value to
indicated if Selected, that will say whether the Font is selected.. This
will be more like a List view control, which gives you a list of items, and
also ability to ready only a list of selected items..

HTH
VJ
 
A

al jones

Not at all, sorry. What I don't see is how to determine which font is the
current font of the collection nor how to set the current font from the
collecti0on. Since one can't delete individual fonts from the collection -
only dispose of the collection at some point - how does one know which of
the fonts would be used...??

Looks like you need to maintain a list of Font's and identify at any point
which one are being used.. and You are on the write path by writing your own
private collection...which I am guessing you have implementing a Collection
Interface or IList Interface.. You could just add a Boolean value to this
PrivateFontCollection.. Expanding on the same line, you can write each
FontCollection item as its own class, and then add a Boolean value to
indicated if Selected, that will say whether the Font is selected.. This
will be more like a List view control, which gives you a list of items, and
also ability to ready only a list of selected items..

HTH
VJ

al jones said:
Okay, I don't have headaches enough from my toy ... If I were to ty to
load
several fontfiles into a PrivateFontCollection, how would I then select
one
to use.

Let's say that I have a couple of fonts, uninstalled of course, in some
directory.

Creating the PrivateFontCollection is pretty self expanatory (or so it
seems) and then loading fonts into that collection also seems pretty
straight forward.

So let's for argument say that I create the collection, load a font that I
then want to immediately use in a RichTextBox (yep, back there) for a
sample of the font; then load another font and use it for a sample ... how
do I know which of the fonts in the collection is 'current' or how would I
set the last font as current [font = fontCollection(ubound)???]. Sorry, I
don't see how to use the fonts in the collection except from the examples
where the collection is walked one font at a time ....

Thanks //al
 
V

VJ

Ok.. no problem, let me try to go with your sample see if that helps,

you are taking a font from your own privatefontcollection and using it for a
object say rich text box, and at some point you want to know which font is
currently being used in the rich text box??

Every item you take a font out and use it for a object (rich textbox) and
use it, you have to
1 . either update the PrivateFontCollection item i.e the Font Item you
took out to indicated it is taken and whichobject using it
2. or Keep a collection property in the rich text box that will hold a
list Font Items being used in rich text box.

If this worng, could you give a outline of source code like the class
struct, then I might or someone here might be able to help better.

VJ

al jones said:
Not at all, sorry. What I don't see is how to determine which font is the
current font of the collection nor how to set the current font from the
collecti0on. Since one can't delete individual fonts from the
collection -
only dispose of the collection at some point - how does one know which of
the fonts would be used...??

Looks like you need to maintain a list of Font's and identify at any
point
which one are being used.. and You are on the write path by writing your
own
private collection...which I am guessing you have implementing a
Collection
Interface or IList Interface.. You could just add a Boolean value to this
PrivateFontCollection.. Expanding on the same line, you can write each
FontCollection item as its own class, and then add a Boolean value to
indicated if Selected, that will say whether the Font is selected.. This
will be more like a List view control, which gives you a list of items,
and
also ability to ready only a list of selected items..

HTH
VJ

al jones said:
Okay, I don't have headaches enough from my toy ... If I were to ty to
load
several fontfiles into a PrivateFontCollection, how would I then select
one
to use.

Let's say that I have a couple of fonts, uninstalled of course, in some
directory.

Creating the PrivateFontCollection is pretty self expanatory (or so it
seems) and then loading fonts into that collection also seems pretty
straight forward.

So let's for argument say that I create the collection, load a font that
I
then want to immediately use in a RichTextBox (yep, back there) for a
sample of the font; then load another font and use it for a sample ...
how
do I know which of the fonts in the collection is 'current' or how would
I
set the last font as current [font = fontCollection(ubound)???]. Sorry,
I
don't see how to use the fonts in the collection except from the
examples
where the collection is walked one font at a time ....

Thanks //al
 
A

al jones

Somewhere I should probably clip this but not sure where - yet.

Let me wing this one time and we'll see if I understand what I think I do:
Dim currentFont As System.Drawing.Font = rtbList.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle

For Each alLine In alWork2
alWork.item1 = Trim(Microsoft.VisualBasic.Left(alLine, 30))
' alWork2 is an arraylist of items containing information about the font in question
' parse out the pieces and construct the line to 'print' (append to the rbt)
rtbList.AppendText(alWork.FontName & vbCrLf)
What I want to do at this point is take the font and rtblist.appendtext a
sample of the font. But, while I have the idea (I think) of how the
private font collection works, don't see how to implement it in the code at
this point.
next alline

More than wanting to know which font to use, I want to be able to use the
font which I just added to the private collection (since I can't add it
till I get to it....)

I'm an old programmer who cut my teeth on APL in the early '70s, wrote
commerical COBOL through the '80s, wrote various versions of BASIC/GWBASIC
in the late '80s and early '90s and started driving a truck in the late
'90s (yeh, for real!). This is really the first application that has
gotten my interest enough to get the tools to actually sit down and code
again - and this just for my own education and interest.

//al

Ok.. no problem, let me try to go with your sample see if that helps,

you are taking a font from your own privatefontcollection and using it for a
object say rich text box, and at some point you want to know which font is
currently being used in the rich text box??

Every item you take a font out and use it for a object (rich textbox) and
use it, you have to
1 . either update the PrivateFontCollection item i.e the Font Item you
took out to indicated it is taken and whichobject using it
2. or Keep a collection property in the rich text box that will hold a
list Font Items being used in rich text box.

If this worng, could you give a outline of source code like the class
struct, then I might or someone here might be able to help better.

VJ

al jones said:
Not at all, sorry. What I don't see is how to determine which font is the
current font of the collection nor how to set the current font from the
collecti0on. Since one can't delete individual fonts from the
collection -
only dispose of the collection at some point - how does one know which of
the fonts would be used...??

Looks like you need to maintain a list of Font's and identify at any
point
which one are being used.. and You are on the write path by writing your
own
private collection...which I am guessing you have implementing a
Collection
Interface or IList Interface.. You could just add a Boolean value to this
PrivateFontCollection.. Expanding on the same line, you can write each
FontCollection item as its own class, and then add a Boolean value to
indicated if Selected, that will say whether the Font is selected.. This
will be more like a List view control, which gives you a list of items,
and
also ability to ready only a list of selected items..

HTH
VJ

Okay, I don't have headaches enough from my toy ... If I were to ty to
load
several fontfiles into a PrivateFontCollection, how would I then select
one
to use.

Let's say that I have a couple of fonts, uninstalled of course, in some
directory.

Creating the PrivateFontCollection is pretty self expanatory (or so it
seems) and then loading fonts into that collection also seems pretty
straight forward.

So let's for argument say that I create the collection, load a font that
I
then want to immediately use in a RichTextBox (yep, back there) for a
sample of the font; then load another font and use it for a sample ...
how
do I know which of the fonts in the collection is 'current' or how would
I
set the last font as current [font = fontCollection(ubound)???]. Sorry,
I
don't see how to use the fonts in the collection except from the
examples
where the collection is walked one font at a time ....

Thanks //al
 
V

VJ

Oh I see... you have a font collection and you want to pick a font that the
current line in RichTextBox is using, and then use it print ? Is this
correct ?

On a lighter note.. I hope the nightmares of BASIC did not make you run from
the programming world.. :)

VJ

al jones said:
Somewhere I should probably clip this but not sure where - yet.

Let me wing this one time and we'll see if I understand what I think I do:
Dim currentFont As System.Drawing.Font = rtbList.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle

For Each alLine In alWork2
alWork.item1 = Trim(Microsoft.VisualBasic.Left(alLine, 30))
' alWork2 is an arraylist of items containing information about
the font in question
' parse out the pieces and construct the line to 'print' (append to
the rbt)
rtbList.AppendText(alWork.FontName & vbCrLf)
What I want to do at this point is take the font and rtblist.appendtext a
sample of the font. But, while I have the idea (I think) of how the
private font collection works, don't see how to implement it in the code
at
this point.
next alline

More than wanting to know which font to use, I want to be able to use the
font which I just added to the private collection (since I can't add it
till I get to it....)

I'm an old programmer who cut my teeth on APL in the early '70s, wrote
commerical COBOL through the '80s, wrote various versions of BASIC/GWBASIC
in the late '80s and early '90s and started driving a truck in the late
'90s (yeh, for real!). This is really the first application that has
gotten my interest enough to get the tools to actually sit down and code
again - and this just for my own education and interest.

//al

Ok.. no problem, let me try to go with your sample see if that helps,

you are taking a font from your own privatefontcollection and using it
for a
object say rich text box, and at some point you want to know which font
is
currently being used in the rich text box??

Every item you take a font out and use it for a object (rich textbox) and
use it, you have to
1 . either update the PrivateFontCollection item i.e the Font Item
you
took out to indicated it is taken and whichobject using it
2. or Keep a collection property in the rich text box that will hold
a
list Font Items being used in rich text box.

If this worng, could you give a outline of source code like the class
struct, then I might or someone here might be able to help better.

VJ

al jones said:
Not at all, sorry. What I don't see is how to determine which font is
the
current font of the collection nor how to set the current font from the
collecti0on. Since one can't delete individual fonts from the
collection -
only dispose of the collection at some point - how does one know which
of
the fonts would be used...??

On Sat, 15 Apr 2006 14:20:19 -0500, VJ wrote:

Looks like you need to maintain a list of Font's and identify at any
point
which one are being used.. and You are on the write path by writing
your
own
private collection...which I am guessing you have implementing a
Collection
Interface or IList Interface.. You could just add a Boolean value to
this
PrivateFontCollection.. Expanding on the same line, you can write each
FontCollection item as its own class, and then add a Boolean value to
indicated if Selected, that will say whether the Font is selected..
This
will be more like a List view control, which gives you a list of items,
and
also ability to ready only a list of selected items..

HTH
VJ

Okay, I don't have headaches enough from my toy ... If I were to ty to
load
several fontfiles into a PrivateFontCollection, how would I then
select
one
to use.

Let's say that I have a couple of fonts, uninstalled of course, in
some
directory.

Creating the PrivateFontCollection is pretty self expanatory (or so it
seems) and then loading fonts into that collection also seems pretty
straight forward.

So let's for argument say that I create the collection, load a font
that
I
then want to immediately use in a RichTextBox (yep, back there) for a
sample of the font; then load another font and use it for a sample ...
how
do I know which of the fonts in the collection is 'current' or how
would
I
set the last font as current [font = fontCollection(ubound)???].
Sorry,
I
don't see how to use the fonts in the collection except from the
examples
where the collection is walked one font at a time ....

Thanks //al
 
A

al jones

Again, no. What I have just appended to the rtb is the name of the font,
along with other information (author, designer, family, etc depending on
the request) at this point I want to take the font file, add it to a font
collection and use it immediately to print a sample of the font ...

//al

Oh I see... you have a font collection and you want to pick a font that the
current line in RichTextBox is using, and then use it print ? Is this
correct ?

On a lighter note.. I hope the nightmares of BASIC did not make you run from
the programming world.. :)

VJ

al jones said:
Somewhere I should probably clip this but not sure where - yet.

Let me wing this one time and we'll see if I understand what I think I do:
Dim currentFont As System.Drawing.Font = rtbList.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle

For Each alLine In alWork2
alWork.item1 = Trim(Microsoft.VisualBasic.Left(alLine, 30))
' alWork2 is an arraylist of items containing information about
the font in question
' parse out the pieces and construct the line to 'print' (append to
the rbt)
rtbList.AppendText(alWork.FontName & vbCrLf)
What I want to do at this point is take the font and rtblist.appendtext a
sample of the font. But, while I have the idea (I think) of how the
private font collection works, don't see how to implement it in the code
at
this point.
next alline

More than wanting to know which font to use, I want to be able to use the
font which I just added to the private collection (since I can't add it
till I get to it....)

I'm an old programmer who cut my teeth on APL in the early '70s, wrote
commerical COBOL through the '80s, wrote various versions of BASIC/GWBASIC
in the late '80s and early '90s and started driving a truck in the late
'90s (yeh, for real!). This is really the first application that has
gotten my interest enough to get the tools to actually sit down and code
again - and this just for my own education and interest.

//al

Ok.. no problem, let me try to go with your sample see if that helps,

you are taking a font from your own privatefontcollection and using it
for a
object say rich text box, and at some point you want to know which font
is
currently being used in the rich text box??

Every item you take a font out and use it for a object (rich textbox) and
use it, you have to
1 . either update the PrivateFontCollection item i.e the Font Item
you
took out to indicated it is taken and whichobject using it
2. or Keep a collection property in the rich text box that will hold
a
list Font Items being used in rich text box.

If this worng, could you give a outline of source code like the class
struct, then I might or someone here might be able to help better.

VJ

Not at all, sorry. What I don't see is how to determine which font is
the
current font of the collection nor how to set the current font from the
collecti0on. Since one can't delete individual fonts from the
collection -
only dispose of the collection at some point - how does one know which
of
the fonts would be used...??

On Sat, 15 Apr 2006 14:20:19 -0500, VJ wrote:

Looks like you need to maintain a list of Font's and identify at any
point
which one are being used.. and You are on the write path by writing
your
own
private collection...which I am guessing you have implementing a
Collection
Interface or IList Interface.. You could just add a Boolean value to
this
PrivateFontCollection.. Expanding on the same line, you can write each
FontCollection item as its own class, and then add a Boolean value to
indicated if Selected, that will say whether the Font is selected..
This
will be more like a List view control, which gives you a list of items,
and
also ability to ready only a list of selected items..

HTH
VJ

Okay, I don't have headaches enough from my toy ... If I were to ty to
load
several fontfiles into a PrivateFontCollection, how would I then
select
one
to use.

Let's say that I have a couple of fonts, uninstalled of course, in
some
directory.

Creating the PrivateFontCollection is pretty self expanatory (or so it
seems) and then loading fonts into that collection also seems pretty
straight forward.

So let's for argument say that I create the collection, load a font
that
I
then want to immediately use in a RichTextBox (yep, back there) for a
sample of the font; then load another font and use it for a sample ...
how
do I know which of the fonts in the collection is 'current' or how
would
I
set the last font as current [font = fontCollection(ubound)???].
Sorry,
I
don't see how to use the fonts in the collection except from the
examples
where the collection is walked one font at a time ....

Thanks //al
 
V

VJ

Yes you can keep adding to the font collection... to access the Font from
the collection.. you can use like a key value pair collection like the
HashTable (so every time a Font is use, you can add a key value pair to
hashtable).. the key can be your fontname, and the value can be a object i.e
a FontItem in your case...Your original question was how to access without
lopping through the collection right?....

VJ


al jones said:
Again, no. What I have just appended to the rtb is the name of the font,
along with other information (author, designer, family, etc depending on
the request) at this point I want to take the font file, add it to a font
collection and use it immediately to print a sample of the font ...

//al

Oh I see... you have a font collection and you want to pick a font that
the
current line in RichTextBox is using, and then use it print ? Is this
correct ?

On a lighter note.. I hope the nightmares of BASIC did not make you run
from
the programming world.. :)

VJ

al jones said:
Somewhere I should probably clip this but not sure where - yet.

Let me wing this one time and we'll see if I understand what I think I
do:

Dim currentFont As System.Drawing.Font = rtbList.SelectionFont
Dim newFontStyle As System.Drawing.FontStyle

For Each alLine In alWork2
alWork.item1 = Trim(Microsoft.VisualBasic.Left(alLine, 30))
' alWork2 is an arraylist of items containing information about
the font in question
' parse out the pieces and construct the line to 'print' (append
to
the rbt)
rtbList.AppendText(alWork.FontName & vbCrLf)
What I want to do at this point is take the font and rtblist.appendtext
a
sample of the font. But, while I have the idea (I think) of how the
private font collection works, don't see how to implement it in the code
at
this point.
next alline

More than wanting to know which font to use, I want to be able to use
the
font which I just added to the private collection (since I can't add it
till I get to it....)

I'm an old programmer who cut my teeth on APL in the early '70s, wrote
commerical COBOL through the '80s, wrote various versions of
BASIC/GWBASIC
in the late '80s and early '90s and started driving a truck in the late
'90s (yeh, for real!). This is really the first application that has
gotten my interest enough to get the tools to actually sit down and code
again - and this just for my own education and interest.

//al

On Sat, 15 Apr 2006 15:15:40 -0500, VJ wrote:

Ok.. no problem, let me try to go with your sample see if that helps,

you are taking a font from your own privatefontcollection and using it
for a
object say rich text box, and at some point you want to know which font
is
currently being used in the rich text box??

Every item you take a font out and use it for a object (rich textbox)
and
use it, you have to
1 . either update the PrivateFontCollection item i.e the Font Item
you
took out to indicated it is taken and whichobject using it
2. or Keep a collection property in the rich text box that will
hold
a
list Font Items being used in rich text box.

If this worng, could you give a outline of source code like the class
struct, then I might or someone here might be able to help better.

VJ

Not at all, sorry. What I don't see is how to determine which font is
the
current font of the collection nor how to set the current font from
the
collecti0on. Since one can't delete individual fonts from the
collection -
only dispose of the collection at some point - how does one know which
of
the fonts would be used...??

On Sat, 15 Apr 2006 14:20:19 -0500, VJ wrote:

Looks like you need to maintain a list of Font's and identify at any
point
which one are being used.. and You are on the write path by writing
your
own
private collection...which I am guessing you have implementing a
Collection
Interface or IList Interface.. You could just add a Boolean value to
this
PrivateFontCollection.. Expanding on the same line, you can write
each
FontCollection item as its own class, and then add a Boolean value to
indicated if Selected, that will say whether the Font is selected..
This
will be more like a List view control, which gives you a list of
items,
and
also ability to ready only a list of selected items..

HTH
VJ

Okay, I don't have headaches enough from my toy ... If I were to ty
to
load
several fontfiles into a PrivateFontCollection, how would I then
select
one
to use.

Let's say that I have a couple of fonts, uninstalled of course, in
some
directory.

Creating the PrivateFontCollection is pretty self expanatory (or so
it
seems) and then loading fonts into that collection also seems pretty
straight forward.

So let's for argument say that I create the collection, load a font
that
I
then want to immediately use in a RichTextBox (yep, back there) for
a
sample of the font; then load another font and use it for a sample
...
how
do I know which of the fonts in the collection is 'current' or how
would
I
set the last font as current [font = fontCollection(ubound)???].
Sorry,
I
don't see how to use the fonts in the collection except from the
examples
where the collection is walked one font at a time ....

Thanks //al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top